r82028 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82027‎ | r82028 | r82029 >
Date:20:40, 12 February 2011
Author:krinkle
Status:ok
Tags:
Comment:
Adding a convenience function to check if a variable is a dom element (instead of a jQuery object, array of dom elements or something totally different).

Note: jQuery itself uses this same check (internally).
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -16,6 +16,15 @@
1717 escapeRE : function( str ) {
1818 return str.replace ( /([\\{}()|.?*+^$\[\]])/g, "\\$1" );
1919 },
 20+ // $.isDomElement( document.getElementById('content') ) === true
 21+ // $.isDomElement( document.getElementsByClassName('portal') ) === false (array)
 22+ // $.isDomElement( document.getElementsByClassName('portal')[0] ) === true
 23+ // $.isDomElement( $('#content') ) === false (jQuery object)
 24+ // $.isDomElement( $('#content').get(0) ) === true
 25+ // $.isDomElement( 'hello world' ) === false
 26+ isDomElement : function( el ) {
 27+ return !!el.nodeType;
 28+ },
2029 isEmpty : function( v ) {
2130 var key;
2231 if ( v === "" || v === 0 || v === "0" || v === null

Follow-up revisions

RevisionCommit summaryAuthorDate
r87360mw.util.test fixes...krinkle21:57, 3 May 2011

Status & tagging log