mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
chore(jqLite): performance reordering
This commit is contained in:
parent
a57141fd1d
commit
bcc3a021eb
2 changed files with 8 additions and 4 deletions
|
|
@ -365,8 +365,12 @@ forEach('input,select,option,textarea,button,form'.split(','), function(value) {
|
|||
BOOLEAN_ELEMENTS[uppercase(value)] = true;
|
||||
});
|
||||
|
||||
function isBooleanAttr(element, name) {
|
||||
return BOOLEAN_ELEMENTS[element.nodeName] && BOOLEAN_ATTR[name.toLowerCase()];
|
||||
function getBooleanAttrName(element, name) {
|
||||
// check dom last since we will most likely fail on name
|
||||
var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()];
|
||||
|
||||
// booleanAttr is here twice to minimize DOM access
|
||||
return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr;
|
||||
}
|
||||
|
||||
forEach({
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ function $CompileProvider($provide) {
|
|||
* @param {string=} attrName Optional none normalized name. Defaults to key.
|
||||
*/
|
||||
$set: function(key, value, writeAttr, attrName) {
|
||||
var booleanKey = isBooleanAttr(this.$$element[0], key.toLowerCase());
|
||||
var booleanKey = getBooleanAttrName(this.$$element[0], key);
|
||||
|
||||
if (booleanKey) {
|
||||
this.$$element.prop(key, value);
|
||||
|
|
@ -498,7 +498,7 @@ function $CompileProvider($provide) {
|
|||
attrs[nName] = value = trim((msie && name == 'href')
|
||||
? decodeURIComponent(node.getAttribute(name, 2))
|
||||
: attr.value);
|
||||
if (isBooleanAttr(node, nName)) {
|
||||
if (getBooleanAttrName(node, nName)) {
|
||||
attrs[nName] = true; // presence means true
|
||||
}
|
||||
addAttrInterpolateDirective(node, directives, value, nName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue