Make sure `_extendedByPrototype`, `_countedByPrototype`, and `prototypeUID` node expandos are accessed with `typeof` to prevent errors in some environments. [#354 state:resolved] (Hilberty, kangax, Andrew Dupont)
This commit is contained in:
parent
26eaa4300b
commit
682a55c2d3
|
@ -1,3 +1,5 @@
|
|||
* Make sure `_extendedByPrototype`, `_countedByPrototype`, and `prototypeUID` node expandos are accessed with `typeof` to prevent errors in some environments. [#354 state:resolved] (Hilberty, kangax, Andrew Dupont)
|
||||
|
||||
* Fix issue where Opera 9.x returns incorrect results on certain Selector queries with descendant combinators. [#395 state:resolved] (Arpan, fearphage, kangax, Andrew Dupont)
|
||||
|
||||
* Null out references to elements in cache on page unload. Need this in addition to the Event#stopObserving calls to clean up memory leaks. [#425 state:resolved] (ykphuah, mr_justin, Andrew Dupont)
|
||||
|
|
|
@ -1508,7 +1508,9 @@ Element.extend = (function() {
|
|||
var Methods = { }, ByTag = Element.Methods.ByTag;
|
||||
|
||||
var extend = Object.extend(function(element) {
|
||||
if (!element || element._extendedByPrototype ||
|
||||
// need to use actual `typeof` operator
|
||||
// to prevent errors in some environments (when accessing node expandos)
|
||||
if (!element || typeof element._extendedByPrototype != 'undefined' ||
|
||||
element.nodeType != 1 || element == window) return element;
|
||||
|
||||
var methods = Object.clone(Methods),
|
||||
|
@ -1735,7 +1737,7 @@ Element.addMethods({
|
|||
if (element === window) {
|
||||
uid = 0;
|
||||
} else {
|
||||
if (Object.isUndefined(element._prototypeUID))
|
||||
if (typeof element._prototypeUID === "undefined")
|
||||
element._prototypeUID = [Element.Storage.UID++];
|
||||
uid = element._prototypeUID[0];
|
||||
}
|
||||
|
|
|
@ -439,7 +439,8 @@ Object.extend(Selector, {
|
|||
if (nodes.length == 0) return nodes;
|
||||
var results = [], n;
|
||||
for (var i = 0, l = nodes.length; i < l; i++)
|
||||
if (!(n = nodes[i])._countedByPrototype) {
|
||||
// use `typeof` operator to prevent errors
|
||||
if (typeof (n = nodes[i])._countedByPrototype == 'undefined') {
|
||||
n._countedByPrototype = Prototype.emptyFunction;
|
||||
results.push(Element.extend(n));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue