Nickolay
On Wed, Dec 2, 2009 at 1:01 PM, Matthew Cline <khym....@gmail.com> wrote:
> I'm trying to fix an extension which was working with FF 3.6 but
> broken with 3.7. The problem is that for an object with a custom
> __iterator__ set, "for (let foo in bar)" never calls __iterator__
> (inserting an "alert()" into the function does nothing), and instead
> iterates over the object's keys (with . Doing "for (let [,foo] in
> Iterator(bar))" iterates over the first character of each key.
> _______________________________________________
> dev-extensions mailing list
> dev-ext...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-extensions
>
> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>
Specifically, it's the result of evaluating an XPath expression in
the
Vimperator extension, which happens when doing hints (pressing 'f' or
'F').
In the _generate() method in common/content/hints.js (some lines cut):
> let res = util.evaluateXPath(this._hintMode.tags(), doc, null, true);
> for (let elem in res) {
And in common/content/util.js:
> evaluateXPath: function (expression, doc, elem, asIterator) {
> if (!doc)
> doc = window.content.document;
> if (!elem)
> elem = doc;
> if (isarray(expression))
> expression = util.makeXPath(expression);
>
> let result = doc.evaluate(expression, elem,
> function lookupNamespaceURI(prefix) {
> return {
> xhtml: "http://www.w3.org/1999/xhtml",
> xhtml2: "http://www.w3.org/2002/06/xhtml2",
> liberator: NS.uri
> }[prefix] || null;
> },
> asIterator ? XPathResult.ORDERED_NODE_ITERATOR_TYPE :
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
> null
> );
>
> 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); };
>
> return result;
> },
Please file a bug with a testcase attached. Thanks,
/be
>
> Nickolay
>
> On Wed, Dec 2, 2009 at 1:01 PM, Matthew Cline <khym.cha...@gmail.com> wrote:
> > I'm trying to fix an extension which was working with FF 3.6 but
> > broken with 3.7. The problem is that for an object with a custom
> > __iterator__ set, "for (let foo in bar)" never calls __iterator__
> > (inserting an "alert()" into the function does nothing), and instead
> > iterates over the object's keys (with . Doing "for (let [,foo] in
> > Iterator(bar))" iterates over the first character of each key.
> > _______________________________________________
> > dev-extensions mailing list
> > dev-extensi...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-extensions