Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Various DOM-related wrappers (Code Worth Recommending Project)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Peter Michaux, post: 4962268"] [snip] The above function will be defined in browsers without ownerDocument or parentNode. NN4 seems to be one example. Wouldn't it be better to write the following? if (typeof getAnElement == 'function') { var html = getAnElement(); var elementDocument = (function() { if (isRealObjectProperty(html, 'ownerDocument')) { return function(el) { return el.ownerDocument; }; } else if (isRealObjectProperty(html, 'parentNode')) { return function(el) { var e; while (e = el.parentNode) { el = e; } return el; }; } })(); } I'm assuming the extra "e" variable is faster than accessing parentNode property twice. [snip] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Various DOM-related wrappers (Code Worth Recommending Project)
Top