Skip to content

Commit

Permalink
fix: __iterator__ set on Xray's XPathResult object not being called
Browse files Browse the repository at this point in the history
  • Loading branch information
caisui committed Nov 1, 2014
1 parent 398f8d3 commit 5c0f44e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions common/content/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,14 @@ const Util = Module("util", {
null
);

if (services.get("vc").compare(Application.version, "33") >= 0
&& Cu.isXrayWrapper(result)) {
let (xr = result, s = asIterator ? "iterateNext" : "snapshotItem") {
result = Object.create(xr);
result[s] = xr[s].bind(xr);
}
}

result.__iterator__ = asIterator
? function () { let elem; while ((elem = this.iterateNext())) yield elem; }
: function () { for (let i = 0; i < this.snapshotLength; i++) yield this.snapshotItem(i); };
Expand Down

0 comments on commit 5c0f44e

Please sign in to comment.