Skip to content
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

Attribute binding empty string and   do weird things #77

Closed
brettw opened this issue Mar 7, 2013 · 3 comments
Closed

Attribute binding empty string and   do weird things #77

brettw opened this issue Mar 7, 2013 · 3 comments

Comments

@brettw
Copy link

brettw commented Mar 7, 2013

if I have a custom component with an attribute foo="" that I publish and use {{foo}} in my component, I get "true" instead of the empty string.

Then I tried   and it gave "NaN" and got much slower. Dimitri said this second issue may already be fixed in WebKit.

@sjmiles
Copy link
Contributor

sjmiles commented Mar 7, 2013

We have trouble here with the nature of attributes as defined by HTML/DOM.

TL;DR:

Currently we follow DOM standards, which means you can do foo=" " (single space) to make foo a string, but if you set foo="" (empty string) it will be true.

The NaN thing is weird, I can't recreate that problem, I may need to see your code.

Long version:

A 'boolean' attribute in HTML is one that exists or does not. For example,

<div hidden>

Has a 'true' hidden attribute. In fact,

<div hidden='false'>

Still has a 'true' hidden attribute (because it exists).

Additionally, markup like

<div foo=''>

is not distinguishable (in DOM) from

<div foo>

In either case, the DOM interpretation of 'foo' is Boolean true.

We may want to tack away from the DOM standard and ignore 'boolean' attributes in favor of some other rules, but it's not decided yet.

@brettw
Copy link
Author

brettw commented Mar 7, 2013

If you can't repro nbsp, then I think you can ignore it, it's probably fixed.

@dfreedm
Copy link
Member

dfreedm commented Apr 16, 2013

See #93

dfreedm pushed a commit that referenced this issue Sep 9, 2016
Fixes #74. The `finalize` technique used in Polymer.Element is not am…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants