Skip to content

Instantly share code, notes, and snippets.

@suvene
Created January 1, 2009 00:59
Show Gist options
  • Save suvene/42168 to your computer and use it in GitHub Desktop.
Save suvene/42168 to your computer and use it in GitHub Desktop.
function $XX(xpath, context, resolver) {
context || (context = document);
var doc = context.ownerDocument || context;
var result = doc.evaluate(xpath, context, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
result.__iterator__ = function() { for (let i = 0, len = this.snapshotLength; i < len; i++) yield this.snapshotItem(i); };
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment