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

The form (or any other readOnly) attribute is not able to be bound to a valid element (button). #10894

Closed
SlexAxton opened this issue Apr 17, 2015 · 4 comments

Comments

@SlexAxton
Copy link
Contributor

tagName: 'button',
attributeBindings: ['form'],
form: 'foobar-form-id',

I think this comes from the fact that the form attribute as a property is readOnly. If you use setAttribute('form', 'foobar-form-id') things are properly updated, but the code path that htmlbars takes is setPropertyStrict which is just element[name] = value;.

Seems reproducible, but hopefully this screenshot is enough:

https://s3.amazonaws.com/f.cl.ly/items/093o1g0m0X0r1b1O1u0X/Screen%20Shot%202015-04-17%20at%203.49.39%20AM.png

You'll notice there's no form attribute even though it is in the attributeBindings list and has a value.

I thought this might be related to this? #10186 unsure though. Not much context.

Here's a fairly reduced test-case of property setting vs. setAttribute: http://jsbin.com/cujani/edit?js,output (note that only button2 ends up with a form attribute). It does seem to be the case that it's intended to be able to be updated, since the spec explicitly outlines how to handle updates.

To make matters worse, it appears that chrome dev, chrome canary, and chromium all throw an error at this line now (which is how I found this out). I didn't report that as the bug because I'm the one using beta browsers, but I think the error might be correct?

Screenshot of that:

http://slex.me/image/1D3c1H303o0h/Screen%20Shot%202015-04-17%20at%203.41.27%20AM.png

The error message is:

Uncaught TypeError: Cannot set property form of # which has only a getter

Which I mostly just paste here for google-ability for when other people hit this. It's not that helpful :D.

So I think we might need a whitelist of readonly attributes? Are there other ones?

@SlexAxton
Copy link
Contributor Author

@mmun - just pinging to see if this premise sounds correct. If so, I might try my hand at patching it. Seems handlebars-y so I chose you, sorry for the direct ping.

@rwjblue
Copy link
Member

rwjblue commented Jun 3, 2015

@SlexAxton - I think this is essentially the same issue as #11221, can you confirm?

@SlexAxton
Copy link
Contributor Author

Yea, look like the same thing. Though I spose this issue could have saved the first half of the sleuthing on that issue 😄 -- maybe I'll be brave and subscribe.

I agree with the whitelist approach, and I think it'd actually not be crazy to find a list of readOnly attributes which are the attributes that throw.

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

No branches or pull requests

3 participants