You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RN 0.82 settled the DOM Node prototype hierarchy, so we can stop
cloning the host node. Object.create(node) makes the raw node the
wrapper's prototype; strict-dom defines its overrides on top;
everything else falls through. Symbol-keyed internals like
INSTANCE_HANDLE_KEY stay reachable through the chain, so RN's
prototype methods work when called on the wrapper.
Changes vs the previous clone:
* No descriptor snapshot. Reads stay in sync with the node.
* No try/catch fallback. defineProperty on a fresh object can't
fail in normal use.
* getBoundingClientRect and the length getters only install when
viewportScale isn't 1. Scale 1 skips them.
* nodeName is a value descriptor now, since tagName.toUpperCase()
doesn't change for a given wrapper.
* writable: true removed from the value descriptors. DOM spec is
read-only for nodeName, getBoundingClientRect and
setSelectionRange, so strict-mode assignments throw now.
* configurable: true on every override.
instanceof still works: the chain is one link longer (wrapper to
node to ReactNativeElement.prototype) but the class prototype is
still on it. Ten tests in html-refs-test.native.js pass.
Copy file name to clipboardExpand all lines: packages/react-strict-dom/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
### Internal
10
10
11
-
*[Native]`useStrictDOMElement` now wraps the underlying React Native host node in a thin `Proxy` instead of cloning it via `Object.create` and `Object.defineProperties`. Strict-dom continues to override `nodeName` (returns uppercase DOM names like `'DIV'`), to scale `getBoundingClientRect` and length properties by the active viewport scale, to polyfill `<img>.complete`, and to polyfill the `setSelectionRange` / `selectionStart` / `selectionEnd`trio on `<input>` / `<textarea>`. All other DOM Node properties and methods (`ownerDocument`, `getRootNode`, `children`, `childNodes`, `parentNode`, `parentElement`, `contains`, `compareDocumentPosition`, pointer-capture methods, legacy `measure*`, etc.) now pass through directly from the underlying RN node.
11
+
*[Native]`useStrictDOMElement` now wraps the RN host node via `Object.create(node)` and defines only strict-dom's overrides as own properties. Non-overridden reads resolve through the prototype chain to the real node, keeping a static hidden class Hermes can optimize. Overrides unchanged: uppercase `nodeName`, viewport-scaled `getBoundingClientRect` and length properties, `<img>.complete`, and `setSelectionRange` / `selectionStart` / `selectionEnd` on `<input>` / `<textarea>`.
0 commit comments