Object prototype mutability causes memory leaks and is unintuitive. This is why patterns like virtualization via proxies and reflection, functional programming's eschewal of side effects, and reactive vue-style object mutation events are commonly used, especially in conjunction with composition techniques.
Matthew Stokeley matthewstokeley
The expected pattern for handling unknown data sources from React's
ssr rendering library, in this case a
data-attribute value, provides an alternative to event propagation and graceful degradation for error handling.
- is the attribute name safe?
- if no, return
- does the node have the attribute?
- if no, return a value of null unless expected is undefined, in which case, return undefined.
- assign the value of
- is the value equal to an empty string? return expected
- otherwise, return the value