marionette-helper
Advanced tools
Comparing version 0.2.2 to 0.3.0
30
index.js
@@ -299,2 +299,32 @@ var Marionette = require('marionette-client'); | ||
}); | ||
}, | ||
/** | ||
* Get the first element that matches the selector by testing the element | ||
* itself and traversing up through its ancestors in the DOM tree. | ||
* | ||
* @param {Marionette.Element|String} el element or some css selector where | ||
* the search should start. | ||
* @param {String} selector A string containing a selector expression to | ||
* match elements against. | ||
* @return {Marionette.Element|undefined} Element found by selector | ||
*/ | ||
closest: function(el, selector) { | ||
if (!isElement(el)) { | ||
el = this.client.findElement(el); | ||
} | ||
var result = this.client.executeScript(function(el, selector) { | ||
// HTMLDocument doesn't have mozMatchesSelector and can't be matched | ||
while (el && el !== document.documentElement) { | ||
// XXX: firefox 30 still needs prefix | ||
if (el.mozMatchesSelector(selector)) { | ||
return el; | ||
} | ||
el = el.parentNode; | ||
} | ||
}, [el, selector]); | ||
// executeScript returns "null" by default | ||
return result || undefined; | ||
} | ||
@@ -301,0 +331,0 @@ }; |
{ | ||
"name": "marionette-helper", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"author": { | ||
"name": "Gareth Aye", | ||
"email": "gaye@mozilla.com" | ||
"name": "The Gaia Team", | ||
"email": "dev-gaia@lists.mozilla.org" | ||
}, | ||
@@ -8,0 +8,0 @@ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26153
15
675
0