Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Mention avoid binding to HTML global properties #90

Closed
ebidel opened this issue Jun 21, 2013 · 7 comments
Closed

Mention avoid binding to HTML global properties #90

ebidel opened this issue Jun 21, 2013 · 7 comments
Assignees
Labels

Comments

@ebidel
Copy link
Contributor

ebidel commented Jun 21, 2013

http://www.w3.org/html/wg/drafts/html/master/dom.html#global-attributes

.style for example, presents all kinds of problems.

@sjmiles
Copy link

sjmiles commented Jun 21, 2013

I think this is a misunderstanding. There is no problem binding to HTML global attributes that I'm aware of.

The known problem area is with overriding native properties. So, if you put title: 'foo' in your prototype, this is an override of the C++ bound title property and weird things can happen. The correct way to initialize this native property would be to put this.title = 'foo' in the ready method.

@ebidel
Copy link
Contributor Author

ebidel commented Jun 21, 2013

It's possible I misunderstood @sorvell.

What about the case where the published property is a native property and you want to initialize it via attribute data binding e.g. <my-element title="{{someTitle}}">? Will the world blow up?

@sorvell
Copy link

sorvell commented Jun 21, 2013

No, that should work just fine. The issue is only doing what Scott
mentioned above:

Problem:

Polymer.register(this, {
title: 'foo'
});

On Fri, Jun 21, 2013 at 4:30 PM, Eric Bidelman notifications@github.comwrote:

It's possible I misunderstood @sorvell https://github.com/sorvell.

What about the case where the published property is a native property and
you want to initialize it via attribute data binding e.g. ? Will the world blow up?


Reply to this email directly or view it on GitHubhttps://github.com//issues/90#issuecomment-19846168
.

@ebidel
Copy link
Contributor Author

ebidel commented Jun 21, 2013

There's a lot of subtly here. How about style? The output of the following is Hello World! [object CSSStyleDeclaration], even though I set this.style in ready(). If certain properties can't be overridden, we need to mention that.

http://jsbin.com/ofoqah/3/edit

<element name="my-element" attributes="style">
  <template><content>Hello World! {{style}}</content></template>
  <script>
    Polymer.register(this, {
      ready: function() { this.style = "foo"; }});
  </script>
</element>

Most people are going to try something similar to this and scratch their head for eternity.

@sjmiles
Copy link

sjmiles commented Jun 22, 2013

style is a property of Element, it's an object of type CSSStyleDeclaration. element.style="foo" makes no sense in any context.

We have an ticket which involves throwing a warning if you attempt to override a native property (which, btw, you should totally be able to do except for for historical browser nasties).

If you think users will find this confusing, I think it means we need a better way of talking about it, because the underlying conceptual model is simple and sane.

@ebidel
Copy link
Contributor Author

ebidel commented Jun 24, 2013

The style example was contrived, but illustrates what people will try to do. I saw it twice in one day.

Warnings will go a long way to help the head scratching. Properties won't be magically gobbled up into browser unknown. Do you have the ticket? To explain it, we have callout under publishing properties that points to source and the list of props that generate warnings.

@arthurevans
Copy link

Should have closed this a while back. There is an explicit caution in this section: http://www.polymer-project.org/docs/polymer/polymer.html#propertiesmethods (under the element prototype chain).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants