I receive "Uncaught DOMException: Failed to set the 'child-count' property on 'DOMStringMap': 'child-count' is not a valid property name." when the following code is executed:
elem.dataset['child-count'] = "test";
where elem is a HTMLElement.
Thought it is legit to use the '-' character within data-attribute names or am I missing something else?
The dataset
properties are camel-cased: elem.dataset.childCount
. They are implicitly transformed to hyphenated attribute names (data-child-count
in your case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With