Type of a node's childNodes property is sometimes a function and not an object #10269
Labels
closed-obsolete
Closed as the reported issue is no longer relevant
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
web-dart2js
This issue was originally filed by umranium...@gmail.com
What steps will reproduce the problem?
What is the expected output? What do you see instead?
You expect the number of children in the node. As is correctly shown when running in chrome.
For the android browser, what you get instead is an exception as given below:
NoSuchMethodError : method not found: '<unknown>'
What version of the product are you using? On what operating system?
Dart Editor build 21823.
Tested on Android v 3.0 (API 11).
Please provide any additional information below.
The problem isn't just with finding the number of nodes in the nodeList, but in most of the other nodeList functions e.g. checking whether the node list is empty, getting the item at a given index, etc.
The actual JavaScript exception thrown says:
TypeError: 'undefined' is not a function (evaluating '$.getInterceptor$asx(receiver).get$length(receiver)')
Further checks revealed that, for example if I had (in JavaScript):
sampleContainer = document.querySelector("#sample_container_id");
The call:
typeof sampleContainer.childNodes
would return "object" in other browsers, but would return "function" in Android's default (WebKit) browser for API < 14.
This might be a bug that has since been fixed, but there are a lot of Android users with Android API < 14, and the fix on Dart's side, is quite simple:
In the function $.getInterceptor$asx
change the line:
if (typeof receiver != "object")
to
if ((typeof receiver != "object") && (typeof receiver != "function"))
Note: There are a lot of other places where the type of an object is checked to be/not to be "object". Similar problems might occur through those checks too. Perhaps having a single function that checks whether an object is a javascript/native object might be a better idea.
I've attached a sample Dart project that does the simple test above.
Attachment:
TestAndroidNodeList.zip (23.18 KB)
The text was updated successfully, but these errors were encountered: