Custom Properties on Standard JavaScript Objects

Adding custom properties directly to a standard built-in JavaScript object can cause issues when the object is serialized. When an object is passed across namespaces or into the global scope, LWS doesn’t reflect this kind of mutation for security reasons.

If you must add custom data to a DOM element, use the dataset property of DOM elements instead of adding custom properties to the element object.

See Also

Alternatives to Mutating Objects