diff --git a/gutenberg b/gutenberg index d6c843be2a..d384e16752 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit d6c843be2a3180da7ee15bbc6c71399d7e55185c +Subproject commit d384e167526d3eec152a707fa7592debc56ec648 diff --git a/src/jsdom-patches.js b/src/jsdom-patches.js index 4ba82d699a..60d7c220d6 100644 --- a/src/jsdom-patches.js +++ b/src/jsdom-patches.js @@ -149,6 +149,21 @@ Node.prototype.insertBefore = function( /* Node */ newChild, /* Node*/ refChild */ Element.prototype.matches = Element.prototype.matchesSelector; +/* + * Implementation of Element.prototype.closest that it's missing from the jsdom-jscore fork we're using. + * See https://github.com/wordpress-mobile/gutenberg-mobile/issues/1625 + */ +Element.prototype.closest = function( selector ) { + let el = this; + while ( el ) { + if ( el.matches( selector ) ) { + return el; + } + el = el.parentElement; + } + return null; +}; + /** * Helper function to check if a node implements the NonDocumentTypeChildNode * interface