Skip to content

Instantly share code, notes, and snippets.

@arlolra
Created March 14, 2015 17:01
Show Gist options
  • Save arlolra/dd72acee363eefa10997 to your computer and use it in GitHub Desktop.
Save arlolra/dd72acee363eefa10997 to your computer and use it in GitHub Desktop.
diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index e4ab596..8579169 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -694,11 +694,22 @@ DOMUtils = DU = {
return this.isList(n) || this.isListItem(n);
},
+ isNestedInListItem: function( n ) {
+ var parentNode = n.parentNode;
+ while ( parentNode ) {
+ if ( this.isListItem( parentNode ) ) {
+ return true;
+ }
+ parentNode = parentNode.parentNode;
+ }
+ return false;
+ },
+
isNestedListOrListItem: function(n) {
- return (this.isList(n) && this.isListItem(n.parentNode)) ||
+ return (this.isList(n) && this.isNestedInListItem(n)) ||
// so, n.parentNode.parentNode is guaranteed to exist
// will be <body> for top-level lists
- (this.isListItem(n) && this.isListItem(n.parentNode.parentNode));
+ (this.isListItem(n) && this.isNestedInListItem(n));
},
isGeneratedFigure: function(n) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment