Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: 3.6 -> 3.7 breakage: __iterator__ being ignored

0 views
Skip to first unread message

Nickolay Ponomarev

unread,
Dec 2, 2009, 7:09:30 AM12/2/09
to Matthew Cline, dev-ext...@lists.mozilla.org, dev-tech-...@lists.mozilla.org
This is a question for dev-tech-js-engine and/or bugzilla. Cross-posted to
js-engine, please follow-up there.

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
>

Donny Viszneki

unread,
Dec 2, 2009, 10:59:46 AM12/2/09
to Nickolay Ponomarev, Matthew Cline, dev-ext...@lists.mozilla.org, dev-tech-...@lists.mozilla.org
Is this really a problem of all objects? That would be quite
surprising. It would be less surprising to find that the iterator of a
specific kind of object was broken.

> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>

--
http://codebad.com/

Matthew Cline

unread,
Dec 2, 2009, 5:00:50 PM12/2/09
to
On Wednesday 02 December 2009 07:59:46 am Donny Viszneki wrote:
> Is this really a problem of all objects? That would be quite
> surprising. It would be less surprising to find that the iterator of a
> specific kind of object was broken.

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;
> },

Brendan Eich

unread,
Dec 5, 2009, 12:48:03 PM12/5/09
to
On Dec 2, 4:09 am, Nickolay Ponomarev <asquee...@gmail.com> wrote:
> This is a question for dev-tech-js-engine and/or bugzilla. Cross-posted to
> js-engine, please follow-up there.

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

0 new messages