An interesting discussion popped up on Slack regarding the currently
supported syntax for accessing object properties.
Currently, Polymer 1.0 supports object.key and array.index, a far cry from
the variety of syntactical options that 0.5’s expressions supported, but *very
much worth the compromise* considering the significant blow that complex
expression parsing deals to performance.
However, take the use case of accessing an object’s properties by key when
the selected key is determined a variable. With Polymer 1.0’s current
support, object.key is not an option. object[key], on the other hand, is
not supported. This leads to:
<my-element some-prop="[[getKey(obj, key)]]"></my-element>
<script>
...
getKey: function(obj, key) {
return obj[key];
}
This seems to be more effort than it is worth for a rather simple and
commonplace operation. Additionally, at a first glance, object[key] doesn’t
seem to be a very complex syntax to add support for, and the aforementioned
implementation seems a tad more expensive in performance, or at least
roughly just as expensive.
However, these are all observations made without any intricate
understanding of the innards of the binding mechanism; I’m no expert on
this topic, I will admit. So, I thought it’d be a good idea to ask:
1. What is the performance cost of supporting object[key]?
2. What is greater - the performance, or the loss of convenience and
terseness?
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/639afb71-c4cf-4785-9259-1bb6e6d0b4b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.