ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

[Failing Test] {{on}} modifier removes valueless attributes

Open kturney opened this issue 6 years ago • 9 comments

Noticed today that using the {{on}} modifier on an element with the required attribute removed the attribute.

e.g. template: <input type='text' required {{on 'input' this.onInput}} > resulted in DOM: <input type='text' >

However, adding a value to the attribute caused it to remain.

e.g. template: <input type='text' required='true' {{on 'input' this.onInput}} > resulted in DOM DOM: <input type='text' required >

While adding a failing test for required, I also added checks for other boolean attributes. autofocus, required, and disabled are all removed, while readonly is preserved.

I believe the problem is with the {{on}} modifier because template: <input type='text' required > results in DOM: <input type='text' required >.

I looked through the {{on}} modifier source and nothing jumped out at me, so maybe it isn't directly an {{on}} problem though?

Side Note: I made the disabled element a button to show that it is not only input that is affected.

kturney avatar Oct 11 '19 04:10 kturney

This appears to occur with any modifier except {{action}}, which leads me to believe this is a VM issue.

pzuraq avatar Nov 12 '19 18:11 pzuraq

We can fix it with an AST transform until we finish the upgrade, which can also be backported to LTS

chancancode avatar Nov 12 '19 18:11 chancancode

VM upgrade is finished...

rwjblue avatar Jan 30 '20 21:01 rwjblue

seems the same as https://github.com/emberjs/ember.js/issues/18712

kturney avatar Jan 30 '20 21:01 kturney

Can you confirm that this is not about boolean attributes, but is actually about valueless attributes (which are often boolean, 😸)?

rwjblue avatar Feb 01 '20 02:02 rwjblue

Would adding a video element with a controls attribute to the test confirm this? I didn't realize there was a distinction.

kturney avatar Feb 01 '20 04:02 kturney

@kturney ya, any attribute would do, even something like <button data-foo {{on 'click' this.wahtever}}>Click Me!</button>. If that works or not will point towards different types of fixes needed...

rwjblue avatar Feb 03 '20 22:02 rwjblue

@rwjblue I added a video element with a controls attribute to the test.

kturney avatar Feb 04 '20 02:02 kturney

Is this still relevant?

kategengler avatar Dec 12 '23 17:12 kategengler