Updates:
Status: Accepted
Labels: -Area-Dart2JS Area-Library
Comment #3 on issue 23574 by
sig...@google.com: Can't access properties of
It looks like this could be a problem in dart:js.
In particular, consider these two lines in the example
var element = new
JsObject.fromBrowserObject(document.createElement('...'));
var proto = element['__proto__'];
Here `element` is a JsObject, but `proto` is not. We seem to be returning
the prototype as an object, and not a JsObject wrapper for it.
This comes down to this code in dart:js:
https://github.com/dart-lang/sdk/blob/c8fb46306c12e96b2a641e1cc0a70c342e40504b/sdk/lib/js/dart2js/js_dart2js.dart#L594
_isLocalObject is true and `o is Node` is true (o is the HtmlElement
prototype, whose interceptor contains $isNode). So we are returning `o`
instead of _wrapToDart(o)
While we fix this, there is a hacky workaround you could use:
import 'dart:html';
import 'dart:js';
main() {
var element = new
JsObject.fromBrowserObject(document.createElement('hello-world'));
var proto = element['__proto__'];
var message = proto is JsObject
? proto['message']
: new JsObject.fromBrowserObject(proto)['message']; // awful awful!
print(message);