HTML5 boolean attribute on a component
See original GitHub issueI need to add an HTML5 boolean attribute to a component. Here’s the Handlebars syntax.
{{#my-component data-test-my-component}}
{{/my-component}}
However, in Emblem.js this doesn’t seem possible. Here’s a few variations I’ve tried:
= my-component data-test-my-component [
some-other-attr='']
= my-component [
data-test-my-component
some-other-attr='' ]
Does Emblem.js support this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
The 24 Boolean Attributes of HTML - Jens Oliver Meiert
The presence of a boolean attribute on an element represents the “true” value, and the absence of the attribute represents the “false” value...
Read more >What does it mean in HTML 5 when an attribute is a boolean ...
A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence...
Read more >Boolean attributes - HTML 5
A number of attributes in HTML5 are boolean attributes . The presence of a boolean attribute on an element represents the true value,...
Read more >How to use boolean attributes in Web Components
The HTML Spec is a little more strict on boolean attributes on built-in elements - it states that the attribute must be set...
Read more >Boolean attributes - HTML Spec
A number of attributes are boolean attributes . The presence of a boolean attribute on an element represents the true value, and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @divmgl the only way to have that “data-” boolean attribute on the root element of your component is to use
attributeBindings
. And this is not related to emblem, the same is true with handlebars.As explained in issue #120 the
div attribute-name=true
syntax allows you to render boolean html attributes.But in the example you gave initially,
data-test-my-component
is expected to be the value for a positional parameter, see: https://guides.emberjs.com/v2.16.0/components/passing-properties-to-a-component/#toc_positional-paramsSo it won’t be bound to a html attribute, Ember will rather look for a
data-test-my-component
property on your rendering context (component, controller) and pass the value of that property as the value for positional parameter, which isn’t what you want.And regarding emblem and positional params the only way to use them is to use the regular inline syntax for attributes (no brackets).
Emblem does support position params inside blocks:
=> example => test