Skip to content

Commit

Permalink
Reorganize the way ElementExtensions are defined. Make sure element…
Browse files Browse the repository at this point in the history
…s used in SpecificElementExtensions are cleaned up.
  • Loading branch information
Juriy Zaytsev committed May 30, 2009
1 parent efb69c9 commit 6e8eba7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/prototype.js
Expand Up @@ -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;
})()
},

Expand Down

2 comments on commit 6e8eba7

@tobie
Copy link

@tobie tobie commented on 6e8eba7 May 30, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@savetheclocktower
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Committed.

Please sign in to comment.