[Greasemonkey] XPCNativeWrappers and Deer Park compatibility

Mark Pilgrim pilgrim at gmail.com
Wed Jul 27 21:46:22 EDT 2005


On 7/27/05, Mark Pilgrim <pilgrim at gmail.com> wrote:
> Until then, keep watching this mailing list, and I'll
> report any new stumbling blocks as I, er, stumble over them.

Here's another subtle problem I encountered.  Consider this code:

var arInputs = document.getElementsByTagName('input');
for (var elmInput in arInputs) {
  ...
}

This no longer works in Deer Park, because arInputs is an
XPCNativeWrapper of an HTMLCollection, and you can't iterate through
an XPCNativeWrapper with an "in" statement.

Instead, you need to do this:

var arInputs = document.getElementsByTagName('input');
for (var i = 0; i < arInputs.length; i++) {
  var elmInput = arInputs[i];
  ...
}

-- 
Cheers,
-Mark


More information about the Greasemonkey mailing list