Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type of a node's childNodes property is sometimes a function and not an object #10269

Closed
DartBot opened this issue Apr 29, 2013 · 6 comments
Closed
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

Comments

@DartBot
Copy link

DartBot commented Apr 29, 2013

This issue was originally filed by umranium...@gmail.com


What steps will reproduce the problem?

  1. Make a simple application that queries the number of children of a node.
  2. Run the application (as Javascript) on chrome.
  3. Run the simple application on the default android browser for android version before 4.0 (API < 14)

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)

@kasperl
Copy link

kasperl commented Apr 29, 2013

cc @rakudrama.
Added Area-Dart2JS, Triaged labels.

@kasperl
Copy link

kasperl commented May 23, 2013

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

4 participants