-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
closes #1369
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,29 +8,29 @@ var hasOwnProp = Object.prototype.hasOwnProperty; | |
* @private | ||
*/ | ||
vjs.createEl = function(tagName, properties){ | ||
var el, propName; | ||
|
||
el = document.createElement(tagName || 'div'); | ||
|
||
for (propName in properties){ | ||
if (hasOwnProp.call(properties, propName)) { | ||
//el[propName] = properties[propName]; | ||
// Not remembering why we were checking for dash | ||
// but using setAttribute means you have to use getAttribute | ||
|
||
// The check for dash checks for the aria-* attributes, like aria-label, aria-valuemin. | ||
// The additional check for "role" is because the default method for adding attributes does not | ||
// add the attribute "role". My guess is because it's not a valid attribute in some namespaces, although | ||
// browsers handle the attribute just fine. The W3C allows for aria-* attributes to be used in pre-HTML5 docs. | ||
// http://www.w3.org/TR/wai-aria-primer/#ariahtml. Using setAttribute gets around this problem. | ||
|
||
if (propName.indexOf('aria-') !== -1 || propName=='role') { | ||
el.setAttribute(propName, properties[propName]); | ||
} else { | ||
el[propName] = properties[propName]; | ||
} | ||
var el; | ||
|
||
tagName = tagName || 'div'; | ||
properties = properties || {}; | ||
|
||
el = document.createElement(tagName); | ||
|
||
vjs.obj.each(properties, function(propName, val){ | ||
// Not remembering why we were checking for dash | ||
// but using setAttribute means you have to use getAttribute | ||
|
||
// The check for dash checks for the aria-* attributes, like aria-label, aria-valuemin. | ||
// The additional check for "role" is because the default method for adding attributes does not | ||
// add the attribute "role". My guess is because it's not a valid attribute in some namespaces, although | ||
// browsers handle the attribute just fine. The W3C allows for aria-* attributes to be used in pre-HTML5 docs. | ||
// http://www.w3.org/TR/wai-aria-primer/#ariahtml. Using setAttribute gets around this problem. | ||
if (propName.indexOf('aria-') !== -1 || propName == 'role') { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gkatsev
Member
|
||
el.setAttribute(propName, val); | ||
} else { | ||
el[propName] = val; | ||
} | ||
} | ||
}); | ||
|
||
return el; | ||
}; | ||
|
||
|
@@ -402,7 +402,7 @@ vjs.setElementAttributes = function(el, attributes){ | |
if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) { | ||
el.removeAttribute(attrName); | ||
} else { | ||
el.setAttribute(attrName,attrValue === true ? '' : attrValue); | ||
el.setAttribute(attrName, (attrValue === true ? '' : attrValue)); | ||
} | ||
}); | ||
}; | ||
|
1 comment
on commit 527a33a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, looks good to me
no sure why you do that, the setAttribute is supported even on ie8 and the performances are better than [] adding this huge block of comment with a "no remembering" and a condition seams odd. But not related to the current pull request.
http://jsperf.com/attribute-vs-setattribute/3