This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24150 - "createAttribute" "setAttributeNode" have no complete alternative
Summary: "createAttribute" "setAttributeNode" have no complete alternative
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: Macintosh All
: P2 minor
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-21 05:50 UTC by punosun
Modified: 2013-12-22 22:38 UTC (History)
4 users (show)

See Also:


Attachments

Description punosun 2013-12-21 05:50:52 UTC
http://dom.spec.whatwg.org/#dom-document-createattribute

[[
createAttribute
]]

http://dom.spec.whatwg.org/#dom-element-setattributenode

[[
setAttributeNode
]]

There is no alternate method provided for setting an attribute with no value.  For example, the only way to set the checked, selected or disabled attribute with no value is with element.setAttributeNode( document.createAttribute( 'selected' ) );

The behavior is subtly different then setting the element property as element.selected = true; because the attribute persists when a form is reset.
Comment 1 Boris Zbarsky 2013-12-21 06:06:53 UTC
What's wrong with setAttribute("selected", "")?
Comment 2 Ms2ger 2013-12-21 07:57:15 UTC
Nothing.
Comment 3 Anne 2013-12-22 22:38:10 UTC
The property for selected="" is defaultSelected, not selected.