Better support for HTML5 attributes#102
Conversation
Better support for HTML5 attributes in Spacebars Helpers. Before HTML5 is not handled properly.
|
@gcacars: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
packages/blaze/attrs.js
Outdated
| return new BooleanHandler(name, value); | ||
| } else if (name === 'spellcheck' && elem.contentEditable === 'true' || | ||
| (elem.tagName === 'TEXTAREA' || | ||
| (elem.tagName === 'INPUT' && elem.type !== 'password'))) { |
There was a problem hiding this comment.
Hm, I think in our code style we are aligning all those (?
Can you improve order/readability/add more parenthesis here because it is unclear how this conditions combine?
There was a problem hiding this comment.
Changed. This way is better?
|
Can you please also add some tests for these changes? |
packages/blaze/attrs.js
Outdated
| return new BooleanHandler(name, value); | ||
| } else if ((name === 'spellcheck' && elem.contentEditable === 'true') || | ||
| (name === 'spellcheck' && elem.tagName === 'TEXTAREA') || | ||
| (name === 'spellcheck' && elem.tagName === 'INPUT' && elem.type !== 'password')) { |
There was a problem hiding this comment.
Hm, maybe:
(name === 'spellcheck' && (elem.contentEditable === 'true' || elem.tagName === 'TEXTAREA' || (elem.tagName === 'INPUT' && elem.type !== 'password'))
There was a problem hiding this comment.
Hmmm... right, I understood now! contenteditable was wrong before. Changed.
packages/blaze/attrs.js
Outdated
| name === 'controls' || name === 'loop' || name === 'muted')) { | ||
| return new BooleanHandler(name, value); | ||
| } else if (name === 'spellcheck' && | ||
| (elem.contentEditable === 'true' || elem.tagName === 'TEXTAREA' || |
There was a problem hiding this comment.
Changed. I did this to be clear that a parenthesis is inside another.
There was a problem hiding this comment.
Hm, I thought you will add one space, not remove it. ;-)
There was a problem hiding this comment.
So that second and third are indented once, but at the same level.
There was a problem hiding this comment.
Sorry, I had not understood. Now is correct?
|
Also, add tests please. |
|
I have no idea which tests you need. Can you help me with this? |
|
Tests. Something like this, just for boolean variables. So you would like to make sure some of those variables are rendered as boolean variables. |
- Alphabetic order for constructors of HTML elements - Issue meteor#52, PR meteor#102
|
Tests failed on CircleCI. I am rerunning them. |
- Removed autocomplete (not a boolean attribute) - Fix names of DOM properties
|
Hm, why those attributes have to be camel case? |
- Spellcheck attribute is a boolean, but is handled like strings. - Fix iframe sandbox with others values - Removed <script> async
- Spellcheck attribute is a boolean, but is handled like strings. - Removed <script> async
|
Can you explain why removing those? |
|
Fixed some bugs. I removed that script async for now. I don't know what happened with him. |
|
Also, add a line to HISTORY file explaining this pull request. So that once it is merged, history will be up-to-date. See example of split |
|
Good that we have tests. :-) Please add tests for all those cases you found as tricky. |
|
Tell me when you think this is ready and complete. |
|
@mitar for me, it's all ok. |
|
Thanks! |
| } else if (elem.tagName === 'FORM' && name === 'novalidate') { | ||
| return new BooleanHandler(name, value); | ||
| } else if (elem.tagName === 'IFRAME' && name === 'sandbox' && !value) { | ||
| // Disable sandbox mode (others values will be handled as a normal attr) |
There was a problem hiding this comment.
Because we can have:
<iframe sandbox>
And this way, the attribute is simply true or false.
Or we can have this others values:
<iframe sandbox="allow-forms">
<iframe sandbox="allow-pointer-lock">
|
A different fix has been implemented in 84c58a6. |
Better support for HTML5 attributes in Spacebars helpers. Before HTML5 boolean attributes is not handled properly.
Fixes: #52