The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.

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