|
|
Created:
11 years, 2 months ago by rafaelw Modified:
11 years, 2 months ago Base URL:
https://github.com/Polymer/TemplateBinding.git@master Visibility:
Public. |
Descriptionmake ref bindable
R=arv
BUG=
Committed: https://github.com/Polymer/TemplateBinding/commit/2799341
Patch Set 1 #Patch Set 2 : moar #Patch Set 3 : moar #
Total comments: 4
MessagesTotal messages: 11
ptal. note that having Template capture bind here is only necessary in cases where MutationObservers are not implemented.
Sign in to reply to this message.
Message was sent while issue was closed.
Committed patchset #3 manually as r2799341 (presubmit successful).
Sign in to reply to this message.
Message was sent while issue was closed.
https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js File src/TemplateBinding.js (right): https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... src/TemplateBinding.js:483: templateObserver.observe(this, { attributes: true, Why are we doing this for ref but not for bind and repeat?
Sign in to reply to this message.
Message was sent while issue was closed.
https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js File src/TemplateBinding.js (right): https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... src/TemplateBinding.js:483: templateObserver.observe(this, { attributes: true, It's an interesting point. Do you think that the attribute values of if, bind, & repeat should be observed and react dynamically as well? ref is somewhat different in that it is bindable, where-as there's no way to bind to the attribute value of bind, if & repeat. On 2014/02/07 18:43:42, arv wrote: > Why are we doing this for ref but not for bind and repeat?
Sign in to reply to this message.
I guess I just don't understand the motivation for treating the ref attribute this way. Why does this one warrant two way binding for the attribute. We don't allow it for any other attribute . On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: > > https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js > File src/TemplateBinding.js (right): > > https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... > src/TemplateBinding.js:483: templateObserver.observe(this, { attributes: > true, > It's an interesting point. Do you think that the attribute values of if, > bind, & repeat should be observed and react dynamically as well? ref is > somewhat different in that it is bindable, where-as there's no way to > bind to the attribute value of bind, if & repeat. > > > On 2014/02/07 18:43:42, arv wrote: >> >> Why are we doing this for ref but not for bind and repeat? > > > https://codereview.appspot.com/59220044/ -- erik
Sign in to reply to this message.
I willing to be convinced. My answer is that ref is useful as a bindable attribute. It's not to hard to imagine switching what is getting stamped based on something dynamic. Binding to the bind/repeat/if seems less obviously useful (at least without asking questions why you didn't do it differently). John? On Mon, Feb 10, 2014 at 8:13 AM, Erik Arvidsson <arv@chromium.org> wrote: > I guess I just don't understand the motivation for treating the ref > attribute this way. Why does this one warrant two way binding for the > attribute. We don't allow it for any other attribute . > > On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: > > > > > https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js > > File src/TemplateBinding.js (right): > > > > > https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... > > src/TemplateBinding.js:483: templateObserver.observe(this, { attributes: > > true, > > It's an interesting point. Do you think that the attribute values of if, > > bind, & repeat should be observed and react dynamically as well? ref is > > somewhat different in that it is bindable, where-as there's no way to > > bind to the attribute value of bind, if & repeat. > > > > > > On 2014/02/07 18:43:42, arv wrote: > >> > >> Why are we doing this for ref but not for bind and repeat? > > > > > > https://codereview.appspot.com/59220044/ > > > > -- > erik >
Sign in to reply to this message.
Really good question :) So with "ref" the idea seems to be that it's a DOM property of HTMLTemplateElement, so it makes sense to reflect the property to the attribute and vice versa. Likewise, it makes sense for it to be bindable. Currently "bind" and "repeat" are not properties of HTMLTemplateElement. In some sense "bind" corresponds to "model". They aren't really interpreted except as part of <template> instantiation. IMHO, it seems like generally a good thing if DOM attributes have corresponding properties, and most of them do. At that point it would be nice if "bind" and "repeat" worked the same as "ref": the property responds to attribute changes, and is data bindable via Node.bind. Whether it is useful or not, I'm not sure. I think the main benefit would be general consistency (especially if "bind" and "model" could be reconciled) but if no one has asked for it, maybe not high priority. On Tue, Feb 11, 2014 at 2:02 PM, Rafael Weinstein <rafaelw@google.com>wrote: > I willing to be convinced. My answer is that ref is useful as a bindable > attribute. It's not to hard to imagine switching what is getting stamped > based on something dynamic. Binding to the bind/repeat/if seems less > obviously useful (at least without asking questions why you didn't do it > differently). > > John? > > > On Mon, Feb 10, 2014 at 8:13 AM, Erik Arvidsson <arv@chromium.org> wrote: > >> I guess I just don't understand the motivation for treating the ref >> attribute this way. Why does this one warrant two way binding for the >> attribute. We don't allow it for any other attribute . >> >> On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: >> > >> > >> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js >> > File src/TemplateBinding.js (right): >> > >> > >> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... >> > src/TemplateBinding.js:483: templateObserver.observe(this, { attributes: >> > true, >> > It's an interesting point. Do you think that the attribute values of if, >> > bind, & repeat should be observed and react dynamically as well? ref is >> > somewhat different in that it is bindable, where-as there's no way to >> > bind to the attribute value of bind, if & repeat. >> > >> > >> > On 2014/02/07 18:43:42, arv wrote: >> >> >> >> Why are we doing this for ref but not for bind and repeat? >> > >> > >> > https://codereview.appspot.com/59220044/ >> >> >> >> -- >> erik >> > >
Sign in to reply to this message.
(oops, meant to CC Pete, he is pretty interested in this topic too) On Tue, Feb 11, 2014 at 3:09 PM, John Messerly <jmesserly@google.com> wrote: > Really good question :) > > So with "ref" the idea seems to be that it's a DOM property of > HTMLTemplateElement, so it makes sense to reflect the property to the > attribute and vice versa. Likewise, it makes sense for it to be bindable. > > Currently "bind" and "repeat" are not properties of HTMLTemplateElement. > In some sense "bind" corresponds to "model". They aren't really interpreted > except as part of <template> instantiation. > > IMHO, it seems like generally a good thing if DOM attributes have > corresponding properties, and most of them do. At that point it would be > nice if "bind" and "repeat" worked the same as "ref": the property responds > to attribute changes, and is data bindable via Node.bind. Whether it is > useful or not, I'm not sure. I think the main benefit would be general > consistency (especially if "bind" and "model" could be reconciled) but if > no one has asked for it, maybe not high priority. > > > On Tue, Feb 11, 2014 at 2:02 PM, Rafael Weinstein <rafaelw@google.com>wrote: > >> I willing to be convinced. My answer is that ref is useful as a bindable >> attribute. It's not to hard to imagine switching what is getting stamped >> based on something dynamic. Binding to the bind/repeat/if seems less >> obviously useful (at least without asking questions why you didn't do it >> differently). >> >> John? >> >> >> On Mon, Feb 10, 2014 at 8:13 AM, Erik Arvidsson <arv@chromium.org> wrote: >> >>> I guess I just don't understand the motivation for treating the ref >>> attribute this way. Why does this one warrant two way binding for the >>> attribute. We don't allow it for any other attribute . >>> >>> On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: >>> > >>> > >>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js >>> > File src/TemplateBinding.js (right): >>> > >>> > >>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... >>> > src/TemplateBinding.js:483: templateObserver.observe(this, { >>> attributes: >>> > true, >>> > It's an interesting point. Do you think that the attribute values of >>> if, >>> > bind, & repeat should be observed and react dynamically as well? ref is >>> > somewhat different in that it is bindable, where-as there's no way to >>> > bind to the attribute value of bind, if & repeat. >>> > >>> > >>> > On 2014/02/07 18:43:42, arv wrote: >>> >> >>> >> Why are we doing this for ref but not for bind and repeat? >>> > >>> > >>> > https://codereview.appspot.com/59220044/ >>> >>> >>> >>> -- >>> erik >>> >> >> >
Sign in to reply to this message.
Message was sent while issue was closed.
https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js File src/TemplateBinding.js (right): https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... src/TemplateBinding.js:443: return Element.prototype.bind.call(this, name, value, oneTime); here's a question, can I bind only a string ID? Or could I bind an HTMLTemplateElement? it seems pretty useful if I could bind an actual element. https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... src/TemplateBinding.js:614: get ref_() { should this be public and settable?
Sign in to reply to this message.
Not to rathole, but my initial feedback on ref was that I expected it to take an HTMLTemplateElement instance rather than an ID. The issue that I was running into was that I had a complex custom element hierarchy and wanted to pass an item renderer (template) from one location to a deeply nested location. For 'repeat', I was expecting a property which is the array to iterate over. That said, with complex controls and virtualization I've mostly moved away from template repeat- but it would be nice if the APIs could be consistent. On Tue, Feb 11, 2014 at 3:10 PM, John Messerly <jmesserly@google.com> wrote: > (oops, meant to CC Pete, he is pretty interested in this topic too) > > > On Tue, Feb 11, 2014 at 3:09 PM, John Messerly <jmesserly@google.com>wrote: > >> Really good question :) >> >> So with "ref" the idea seems to be that it's a DOM property of >> HTMLTemplateElement, so it makes sense to reflect the property to the >> attribute and vice versa. Likewise, it makes sense for it to be bindable. >> >> Currently "bind" and "repeat" are not properties of HTMLTemplateElement. >> In some sense "bind" corresponds to "model". They aren't really interpreted >> except as part of <template> instantiation. >> >> IMHO, it seems like generally a good thing if DOM attributes have >> corresponding properties, and most of them do. At that point it would be >> nice if "bind" and "repeat" worked the same as "ref": the property responds >> to attribute changes, and is data bindable via Node.bind. Whether it is >> useful or not, I'm not sure. I think the main benefit would be general >> consistency (especially if "bind" and "model" could be reconciled) but if >> no one has asked for it, maybe not high priority. >> >> >> On Tue, Feb 11, 2014 at 2:02 PM, Rafael Weinstein <rafaelw@google.com>wrote: >> >>> I willing to be convinced. My answer is that ref is useful as a bindable >>> attribute. It's not to hard to imagine switching what is getting stamped >>> based on something dynamic. Binding to the bind/repeat/if seems less >>> obviously useful (at least without asking questions why you didn't do it >>> differently). >>> >>> John? >>> >>> >>> On Mon, Feb 10, 2014 at 8:13 AM, Erik Arvidsson <arv@chromium.org>wrote: >>> >>>> I guess I just don't understand the motivation for treating the ref >>>> attribute this way. Why does this one warrant two way binding for the >>>> attribute. We don't allow it for any other attribute . >>>> >>>> On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: >>>> > >>>> > >>>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js >>>> > File src/TemplateBinding.js (right): >>>> > >>>> > >>>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... >>>> > src/TemplateBinding.js:483: templateObserver.observe(this, { >>>> attributes: >>>> > true, >>>> > It's an interesting point. Do you think that the attribute values of >>>> if, >>>> > bind, & repeat should be observed and react dynamically as well? ref >>>> is >>>> > somewhat different in that it is bindable, where-as there's no way to >>>> > bind to the attribute value of bind, if & repeat. >>>> > >>>> > >>>> > On 2014/02/07 18:43:42, arv wrote: >>>> >> >>>> >> Why are we doing this for ref but not for bind and repeat? >>>> > >>>> > >>>> > https://codereview.appspot.com/59220044/ >>>> >>>> >>>> >>>> -- >>>> erik >>>> >>> >>> >> >
Sign in to reply to this message.
I'm willing to consider allowing the ref binding to accept both a string which is treated as an id reference, or an actual template element reference. I'm interested in hearing specific use cases for the later. On Tue, Feb 11, 2014 at 3:32 PM, Pete Blois <blois@google.com> wrote: > Not to rathole, but my initial feedback on ref was that I expected it to > take an HTMLTemplateElement instance rather than an ID. The issue that I > was running into was that I had a complex custom element hierarchy and > wanted to pass an item renderer (template) from one location to a deeply > nested location. For 'repeat', I was expecting a property which is the > array to iterate over. That said, with complex controls and virtualization > I've mostly moved away from template repeat- but it would be nice if the > APIs could be consistent. > > > On Tue, Feb 11, 2014 at 3:10 PM, John Messerly <jmesserly@google.com>wrote: > >> (oops, meant to CC Pete, he is pretty interested in this topic too) >> >> >> On Tue, Feb 11, 2014 at 3:09 PM, John Messerly <jmesserly@google.com>wrote: >> >>> Really good question :) >>> >>> So with "ref" the idea seems to be that it's a DOM property of >>> HTMLTemplateElement, so it makes sense to reflect the property to the >>> attribute and vice versa. Likewise, it makes sense for it to be bindable. >>> >>> Currently "bind" and "repeat" are not properties of HTMLTemplateElement. >>> In some sense "bind" corresponds to "model". They aren't really interpreted >>> except as part of <template> instantiation. >>> >>> IMHO, it seems like generally a good thing if DOM attributes have >>> corresponding properties, and most of them do. At that point it would be >>> nice if "bind" and "repeat" worked the same as "ref": the property responds >>> to attribute changes, and is data bindable via Node.bind. Whether it is >>> useful or not, I'm not sure. I think the main benefit would be general >>> consistency (especially if "bind" and "model" could be reconciled) but if >>> no one has asked for it, maybe not high priority. >>> >>> >>> On Tue, Feb 11, 2014 at 2:02 PM, Rafael Weinstein <rafaelw@google.com>wrote: >>> >>>> I willing to be convinced. My answer is that ref is useful as a >>>> bindable attribute. It's not to hard to imagine switching what is getting >>>> stamped based on something dynamic. Binding to the bind/repeat/if seems >>>> less obviously useful (at least without asking questions why you didn't do >>>> it differently). >>>> >>>> John? >>>> >>>> >>>> On Mon, Feb 10, 2014 at 8:13 AM, Erik Arvidsson <arv@chromium.org>wrote: >>>> >>>>> I guess I just don't understand the motivation for treating the ref >>>>> attribute this way. Why does this one warrant two way binding for the >>>>> attribute. We don't allow it for any other attribute . >>>>> >>>>> On Sat, Feb 8, 2014 at 7:33 PM, <rafaelw@chromium.org> wrote: >>>>> > >>>>> > >>>>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js >>>>> > File src/TemplateBinding.js (right): >>>>> > >>>>> > >>>>> https://codereview.appspot.com/59220044/diff/40001/src/TemplateBinding.js#new... >>>>> > src/TemplateBinding.js:483: templateObserver.observe(this, { >>>>> attributes: >>>>> > true, >>>>> > It's an interesting point. Do you think that the attribute values of >>>>> if, >>>>> > bind, & repeat should be observed and react dynamically as well? ref >>>>> is >>>>> > somewhat different in that it is bindable, where-as there's no way to >>>>> > bind to the attribute value of bind, if & repeat. >>>>> > >>>>> > >>>>> > On 2014/02/07 18:43:42, arv wrote: >>>>> >> >>>>> >> Why are we doing this for ref but not for bind and repeat? >>>>> > >>>>> > >>>>> > https://codereview.appspot.com/59220044/ >>>>> >>>>> >>>>> >>>>> -- >>>>> erik >>>>> >>>> >>>> >>> >> >
Sign in to reply to this message.
|