Skip to content

Commit 5c0f44e

Browse files
committed
fix: __iterator__ set on Xray's XPathResult object not being called
1 parent 398f8d3 commit 5c0f44e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

common/content/util.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,14 @@ const Util = Module("util", {
406406
null
407407
);
408408

409+
if (services.get("vc").compare(Application.version, "33") >= 0
410+
&& Cu.isXrayWrapper(result)) {
411+
let (xr = result, s = asIterator ? "iterateNext" : "snapshotItem") {
412+
result = Object.create(xr);
413+
result[s] = xr[s].bind(xr);
414+
}
415+
}
416+
409417
result.__iterator__ = asIterator
410418
? function () { let elem; while ((elem = this.iterateNext())) yield elem; }
411419
: function () { for (let i = 0; i < this.snapshotLength; i++) yield this.snapshotItem(i); };

0 commit comments

Comments
 (0)