diff --git a/CHANGELOG b/CHANGELOG index 6b8f650..19f5069 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Reorganize the way `ElementExtensions` are defined. Make sure elements used in SpecificElementExtensions are cleaned up. (kangax) + * Make sure $A works with primitive values. (mr_justin, kangax) * Do not browser sniff when forking `unmark` function in selector suite. Instead use a proper test - PROPERTIES_ATTRIBUTES_MAP. (kangax) diff --git a/src/prototype.js b/src/prototype.js index 9d0b667..035a690 100644 --- a/src/prototype.js +++ b/src/prototype.js @@ -27,23 +27,25 @@ var Prototype = { XPath: !!document.evaluate, SelectorsAPI: !!document.querySelector, ElementExtensions: (function() { - if (window.HTMLElement && window.HTMLElement.prototype) - return true; - if (window.Element && window.Element.prototype) - return true; + var constructor = window.Element || window.HTMLElement; + return !!(constructor && constructor.prototype); })(), - SpecificElementExtensions: (function() { + SpecificElementExtensions: (function() { // First, try the named class if (typeof window.HTMLDivElement !== 'undefined') return true; var div = document.createElement('div'); - if (div['__proto__'] && div['__proto__'] !== - document.createElement('form')['__proto__']) { - return true; + var form = document.createElement('form'); + var isSupported = false; + + if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) { + isSupported = true; } - return false; + div = form = null; + + return isSupported; })() },