Lusito / tsx-dom

Lightweight DOM Libraries
https://lusito.github.io/tsx-dom/
MIT License
49 stars 17 forks source link

`style` attributes not working in Firefox #13

Closed krmax44 closed 2 years ago

krmax44 commented 2 years ago

It seems that Firefox returns false for all style attributes of DOM elements, causing style attributes to be missing.

Example:

const el = document.createElement('div')
console.log(Object.prototype.hasOwnProperty.call(el.style, 'width')) // Chrome: true, Firefox: false

https://github.com/Lusito/tsx-dom/blob/5c69c12882c3797d1d4d2f51f6de341b69912190/src/index.ts#L26

Therefore, no style on Firefox. I'd suggest optimistically copying all attributes to target.style no matter what. Shouldn't break anything, if the property doesn't exist.

Lusito commented 2 years ago

Thanks for the report and the PR. I changed it a bit, but left you as co-author.

Lusito commented 2 years ago

Version 1.4.0 has just been released