This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Array-like types in the DOM do not support index access #173
Closed
Activity
jmesserly commentedon May 8, 2015
#138 might help here. But not sure if we consider indexer methods as extension ones or not.
jmesserly commentedon May 18, 2015
what's going wrong here is a bit complex, here's some thoughts.
First off, static dispatch. We never generate
[]
at the moment for JS indexable (native) types. I think it was just never implemented. Arrays work because they have an extension method for[]
and[]=
(it does bounds checking), so we did not have to add this feature for them.Here's how NodeList is defined (warning, big file: dom.dart#L10158)
if we statically know it's a native [] operator, two options:
length
getter)I'd lean towards the latter. Compiler shouldn't make up a bounds check function without user asking for it. That said, we could make something that a type can opt-in to, and perhaps use that in
dart:html
but notdart:dom
. (Also extension methods will only work if it's a nominal type in JS, else we can't reliably extend all instances.)jmesserly commentedon May 18, 2015
Another wrinkle: for the dart:core types, we want to assume that all methods will be Dart defined, and native methods are all hidden from dynamic dispatch. That is, extension methods are all or nothing as we currently use them. For dart:html types, I presume we want most native methods to appear, some hidden, and some extensions? That will make things a little more complicated. We can probably make it work though
jmesserly commentedon May 19, 2015
https://codereview.chromium.org/1145833004/ makes it possible to define native JS indexers on the
@JsName()
typeRevert "fixes #173, ability to use native JS indexers"
jmesserly commentedon Jun 4, 2015
I'm going to wait for the fix big #138 patch (https://codereview.chromium.org/1153003003/) to land and then take another look here.
jmesserly commentedon Jun 4, 2015
rebased against that fix, should be good to go