Comments (8)
edited subject. Based on your link, I think the issue is property paths like obj["+foo"]
don't currently work.
from observe-js.
No, obj["+foo"]
works perfectly. What doesn't work is obj["foo"]
and obj[1]
if obj
is a Map
Why `obj["+foo"] works
obj["+foo"]
is correctly parsed into [#obj, "+foo"]
Why obj["foo"]
doesn't work
obj["foo"]
is parsed into [#obj, #foo]
instead of [#obj, "foo"]
, and #foo
may not exist in generated code
Why obj[1]
doesn't work if obj
is a Map
_getObjectProperty
and _setObjectProperty
only handle List indexers and ignore Map integer indexers.
_getObjectProperty(object, property) {
if (object == null) return null;
if (property is int) {
if (object is List && property >= 0 && property < object.length) {
return object[property];
}
} else if (property is String) {
return object[property];
} else if (property is Symbol) {
...
}
bool _setObjectProperty(object, property, value) {
if (object == null) return false;
if (property is int) {
if (object is List && property >= 0 && property < object.length) {
object[property] = value;
return true;
}
} else if (property is Symbol) {
...
}
This problem results from a difference between JS and Dart. In JS, obj.foo
and obj["foo"]
are identical while, in Dart, they are two completely different things. So not everything that works in JS can work in Dart.
To fix this problem, the parser should reserve indexers (whether they are Map indexers or List indexers) instead of trying to convert them into symbols.
- identifiers => symbols
- string indexers => strings
- int indexers => int's
from observe-js.
@jolleekin I think you're talking about Dart-specific issues. Those are tracked at https://code.google.com/p/dart/issues/detail?id=20294
from observe-js.
(This issue tracker is only for issues related to the JavaScript implementation)
from observe-js.
I know. The problem is observe-dart is implemented based on observe-js. If something doesn't work in the Dart implementation, it must be reflected back to the JS implementation. That's why I opened this issue.
Sent from my Windows Phone
From: John Messerlymailto:[email protected]
Sent: 8/12/2014 1:46 AM
To: Polymer/observe-jsmailto:[email protected]
Cc: Man Hoangmailto:[email protected]
Subject: Re: [observe-js] PathObserver doesn't support String keys in index expressions (#64)
(This issue tracker is only for issues related to the JavaScript implementation)
Reply to this email directly or view it on GitHub:
#64 (comment)
from observe-js.
Ah, gotcha. But I wouldn't say it so strongly. There can be differences, if it makes sense. For example, in the case of Map, it's a Dart type and doesn't need (and couldn't) be handled in JavaScript. Same thing with Symbol vs String. That should be addressed in the Dart code (https://code.google.com/p/dart/issues/detail?id=20294). That's why for this bug, we focus only on problems that can be recreated in JavaScript.
from observe-js.
Maybe I took sigmund's words too serious ("that is also how the JS implementation is written. We have to follow up with them to make sure we are consistent."). Anyway, if the Dart team agrees there can be differences, this issue can be closed.
from observe-js.
Ok. I'm closing this. If someone feels there is an actual bug in the JS impl, please post a jsbin with expected/actual behavior.
from observe-js.
Related Issues (20)
- .set doesnt work with computed bindings, computed properties, or observers
- FTLOG HOT 3
- TypeError: Object.observe is not a function HOT 2
- Build system seems to be broken
- Ability to have performMicrotaskCheckpoint not attached to global
- Use regular expressions instead of state machine HOT 3
- Even faster compiledGetValueFromFn HOT 1
- Is this supposed to work? HOT 3
- Support AMD loading with "define"
- version on npm is 0.4.2 while releases here on github show latest as 0.5.6 HOT 5
- utlise proxy on systems where Proxy is supported HOT 1
- 7 tests broken on latest FF and 6 on Chrome
- Pathobserver on document.title - works in ff, not in chrome
- Supress Object.observe deprecation warning
- IGNORE
- ObjectObserver does not report observed object onChange event
- Chrome 50 breaks this lib HOT 11
- About delivery of changes
- ObjectObserver doesn't seem to work in Safari iOS HOT 3
- Tag with ^1.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from observe-js.