-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Infer Element subclass from query() parameter #4238
Comments
Removed Type-Defect label. |
Hm... @mndrix, do you think that specifying element type in "query" is something usual? |
This comment was originally written by mndr...@gmail.com A quick analysis of one of my larger JavaScript projects shows that 46% of our jQuery CSS selectors use element types in a way that Editor inference would succeed. My Dart code base isn't as big, but I assume it will follow the same proportion. I agree that developers will use element types in query() selectors more frequently once they know that it helps inference. If the Editor implements an inference technique, I think many developers will discover it (like I discovered 'as' inference). |
Added Accepted label. |
https://chromiumcodereview.appspot.com/10825135 Added Started label. |
https://code.google.com/p/dart/source/detail?r=10128 Now we support simple selectors in query(). We don't support "body div", i.e. any selector with space, because we can not prove (without full CSS selector parsing) that space is separator of elements, not part of attribute value in "input[value='my value']". Added Fixed label. |
This issue was originally filed by mn...@gmail.com
In the Dart Editor, if I write dart:html code like this:
var input = form.query("input.subject");
var subject = input.value;
I get a warning on
input.value
saying ""value" is not a member of Element". To fix the warning, I insert a cast:var input = form.query("input.subject") as InputElement;
var subject = input.value;
Because the query string is "input.subject", it's obvious that query() returns an InputElement (or null). Where possible, the Editor should infer Element subclasses from the argument to query(). It can fall back to Element if inference fails.
The text was updated successfully, but these errors were encountered: