Object support for the `style` attribute.
See original GitHub issueIf I try to make a reactive style value, then the value of the CSS property in the style attribute is overwritten.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>arrow-js</title>
</head>
<body>
<div id="app"></div>
<script type='module'>
import { reactive, html } from 'https://unpkg.com/@arrow-js/core@1.0.0-alpha.5/dist/index.min.mjs';
const state = reactive({
color: 'red'
});
html`
<button style="background-color: ${() => state.color}">click me</button>
`(document.getElementById('app'))
</script>
</body>
</html>
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
HTML object style Attribute - Dofactory
The style attribute specifies the style, i.e. look and feel, of the <object> element. A style contains any number of CSS property/value pairs,...
Read more >The Style Information element - HTML - MDN Web Docs
This attribute defines which media the style should be applied to. Its value is a media query, which defaults to all if the...
Read more >HTML style Attribute - W3Schools
The style attribute specifies an inline style for an element. The style attribute will override any style set globally, e.g. styles specified in...
Read more >Support both object and string as value for style attribute. #756
You should be able to use a string or an object to set the style attribute of an element now! With a string....
Read more >How To Modify Attributes, Classes, and Styles in the DOM
Attributes are values that contain additional information about HTML elements. They usually come in name/value pairs, and may be essential ...
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
Thanks. I realized that I can do this and it will work.
It’s true that HTML supports only strings as attributes, but DOM HTMLElement supports any type of attributes.
I was hoping I could set these attributes easily with arrow. Now I have to get reference to element and set the attribute value with JS
JSON stringify is just bad design. Not going to use that.
Lit has solved this by having dot notation in templates. https://lit.dev/docs/templates/expressions/#property-expressions