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
PropertyPath in observe v0.11.0 still doesn't support Map indexers #20294
Comments
This comment was originally written by @zoechi is this related to https://code.google.com/p/dart/issues/detail?id=20286 ? |
This comment was originally written by @jolleekin I don't think so. Polymer doesn't use PropertyPath. |
Thanks for the detailed bug description. This makes sense now. Re (1): that is also how the JS implementation is written. We have to follow up with them to make sure we are consistent. Removed Priority-Unassigned label. |
This comment was originally written by @jolleekin I opened a new issue for the JS implementation. |
i think this is fixed, https://github.com/dart-lang/observe/blob/master/lib/src/path_observer.dart#L116 if not it's now possible to pass in a list to PropertyPath ['foo', 'bar', '+baz'] Added AssumedStale label. |
This comment was originally written by @jolleekin It's not fixed though. Take a look at [_setObjectProperty]. This method doesn't check for strings. If you pass a list that contains strings and Symbols, [_setObjectProperty] will fail. bool _setObjectProperty(object, property, value) { if (property is int) { if (_logger.isLoggable(Level.FINER)) { To fix the problem, [_setObjectProperty] needs to handle strings as follows. bool _setObjectProperty(object, property, value) { if (property is int) { if (_logger.isLoggable(Level.FINER)) { |
This issue has been moved to dart-archive/observe#68. |
This issue was originally filed by @jolleekin
import 'package:observe/observe.dart';
main() {
var p = new PropertyPath('resources["commands"]["+add"]');
// Output: resources.commands["+add"]
// Expect: resources["commands"]["+add"]
print(p);
}
"commands" is actually converted into a symbol while "+add" is left as is.
Ideally, indexers should be left as is whether they are Map indexers or List indexers.
The following code only checks for integer List indexers and forgets about integer Map indexers.
// path_observe.dart
_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) {
...
}
...
}
What version of the product are you using?
observe 0.11.0
On what operating system?
What browser (if applicable)?
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: