Skip to content

fix(js): bind computed style methods passed through to the declaration - #636

Open
marcoripa96 wants to merge 1 commit into
h4ckf0r0day:mainfrom
marcoripa96:fix/635-computed-style-methods
Open

fix(js): bind computed style methods passed through to the declaration#636
marcoripa96 wants to merge 1 commit into
h4ckf0r0day:mainfrom
marcoripa96:fix/635-computed-style-methods

Conversation

@marcoripa96

Copy link
Copy Markdown

Fixes #635.

getComputedStyle wraps the element's live style proxy, and its get trap handed pass-through methods back unbound. Called through the computed object, setProperty/removeProperty then ran _pull() with this bound to the wrapper, where the declaration's own fields (_loaded, _owner) miss the style proxy's has trap and read as "" from the CSS lookup, so the call threw TypeError: this._owner.getAttribute is not a function.

On current main the getPropertyValue/item/length/cssText names already have computed fallbacks ahead of the passthrough (since the geometry/computed-styles work), which fixed the jQuery .css()/.show() symptom described in the issue for main. This PR closes the remaining hole by binding whatever still falls through to the declaration, and adds a regression test covering every method reachable through the computed proxy so the v0.1.11 failure mode cannot come back.

Test plan:

  • cargo nextest run -p obscura -E 'test(computed_style_methods)': fails on main at set_property with the _owner TypeError, passes with the fix.
  • cargo nextest run -p obscura -p obscura-cdp -p obscura-cli -p obscura-mcp: 196 passed, 3 skipped.
  • Obstacle course: 32/33 with and without this change; the failing observer-intersection stage fails identically on unpatched main (verified by stashing the fix and rebuilding), so it is pre-existing and unrelated.

getComputedStyle wraps the element's live style proxy, and its get trap
handed pass-through methods back unbound. Called through the computed
object, setProperty/removeProperty then ran _pull() with `this` bound to
the wrapper, where the declaration's own fields (_loaded, _owner) miss the
style proxy's has trap and read as "" from the CSS lookup, so the call
threw "this._owner.getAttribute is not a function".
getPropertyValue/item/length already have computed fallbacks ahead of the
passthrough; bind whatever still falls through to the declaration.

Adds a regression test covering every method reachable through the
computed proxy on a v0.1.11-era failure (jQuery curCSS reads
computed.getPropertyValue, so .css() and .show() crashed on real sites).

Fixes h4ckf0r0day#635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getComputedStyle() methods throw "this._owner.getAttribute is not a function" on every element (breaks jQuery .css()/.show())

2 participants