question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style attribute isn’t set in DOM

See original GitHub issue

Hi! Thank you for the lib!

Ran into an issue with a missing style tag:

const { h } = require('picodom')
const hyperx = require('hyperx')
const html = hyperx(h, {attrToProp: false})

const a = html`<div style="height: 100%; background-color: red;">123</div>`
console.log(a)

console: screen shot 2017-08-27 at 9 45 02 pm

DOM:

<div>123</div>

Tried in the example pen (thought maybe hyperx is to blame), same thing:

https://codepen.io/anon/pen/jLvjOQ?editors=0110

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mindplay-dkcommented, Dec 10, 2017

Having thought more about this, I’ve changed my mind.

One reason not to support strings, is it makes it impossible to incrementally patch CSS properties, since you can’t directly diff between a string and an object - or, at least not without rolling out a CSS parser for the string first, which is likely out of the question. So, if we support strings, we’ll invite weird edge-cases where the style-property changes to/from a string/object.

Another argument is why use strings in the first place? Is there ever a good reason to do that?

The use of style in the first place, is likely mostly interesting for things like toggling state (collapse/expand, etc.) and hopefully never as a means of actually styling UI elements - for that, a CSS-in-JS framework, or just a good’ol CSS file and the class attribute, are likely much preferable. It’s likely not worth sweating over?

1reaction
leeoniyacommented, Dec 9, 2017

I find life without surprises rather boring.

this is more “surprise, a flat tire!” than “surprise, a trip to italy!”. to be fair, i do prefer all my network switches to randomly drop packets; i haven’t bought a boring, predictable switch in years. 😆

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS can't set style property - Stack Overflow
Yeah I need all styles from older td to be copied to new td. Entire object. As Sebastian mentioned, style is read-only property....
Read more >
Working with Attributes on DOM Elements - CSS-Tricks
Some HTML elements accept width and height as attributes. Some do not. Those attributes are sometimes referred to as presentational attributes.
Read more >
Set style attributes directly instead of using cssText for inline ...
I am working on an app where there is a lot of motion and positions that are updated dynamically based on the state....
Read more >
HTML attribute: disabled - HTML: HyperText Markup Language
The Boolean disabled attribute, when present, makes the element not ... If this attribute isn't set, the button can still be disabled from ......
Read more >
Searching: getElement*, querySelector*
DOM navigation properties are great when elements are close to each other. ... inlined into HTML, but generally isn't a good thing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found