Skip to content

Commit

Permalink
Do not browser sniff when forking unmark function in selector suite…
Browse files Browse the repository at this point in the history
…. Instead use a proper test - PROPERTIES_ATTRIBUTES_MAP.
  • Loading branch information
Juriy Zaytsev authored and savetheclocktower committed May 16, 2009
1 parent 7437434 commit cebf7d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Do not browser sniff when forking `unmark` function in selector suite. Instead use a proper test - PROPERTIES_ATTRIBUTES_MAP. (kangax)

* Do not use short-hand element methods notation (@element.getStyle() -> Element.getStyle(@element)) for performance reasons. Do not use `$A` and `Array.prototype.shift` when `Array.prototype.slice` can be used instead. (kangax)

* `Prototype.Browser.Opera` now uses stronger inference and is determined by [[Class]] of `window.opera` being - "Opera". (kangax)
Expand Down
39 changes: 27 additions & 12 deletions src/dom/selector.js
Expand Up @@ -437,11 +437,33 @@ Object.extend(Selector, {
return nodes;
},

unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._countedByPrototype = undefined;
return nodes;
},
unmark: (function(){

// IE improperly serializes _countedByPrototype in (inner|outer)HTML
// due to node properties being mapped directly to attributes
var PROPERTIES_ATTRIBUTES_MAP = (function(){
var el = document.createElement('div'),
isBuggy = false,
propName = '_countedByPrototype',
value = 'x'

This comment has been minimized.

Copy link
@staaky

staaky May 16, 2009

forgot a ; here

el[propName] = value;
isBuggy = (el.getAttribute(propName) === value);
el = null;
return isBuggy;
});

return PROPERTIES_ATTRIBUTES_MAP ?
function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node.removeAttribute('_countedByPrototype');
return nodes;
} :
function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._countedByPrototype = void 0;
return nodes;
}
})(),

// mark each child node with its position (for nth calls)
// "ofType" flag indicates whether we're indexing for nth-of-type
Expand Down Expand Up @@ -831,13 +853,6 @@ if (Prototype.Browser.IE) {
for (var i = 0, node; node = b[i]; i++)
if (node.tagName !== "!") a.push(node);
return a;
},

// IE improperly serializes _countedByPrototype in (inner|outer)HTML.
unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node.removeAttribute('_countedByPrototype');
return nodes;
}
});
}
Expand Down

0 comments on commit cebf7d6

Please sign in to comment.