Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #570
Problem
toHaveStyle()could never match theaspect-ratioCSS property. jsdom does not implementaspect-ratio(itscssstyledependency has a fixed property list), so it silently drops the declaration — both when parsing thestyleattribute and in computed styles:getComputedStyle(el)['aspect-ratio']isundefinedandgetPropertyValue('aspect-ratio')is''. The expected side parses fine, so the failure was purely on the received side inisSubset.Fix
Added a guarded fallback in
isSubset: when the computed style doesn't know a property at all (computedStyle[name] === undefined && getPropertyValue(name) === ''), the matcher compares against the element's own style declaration instead. The guard preserves existing semantics for known properties (e.g.!importantcorner cases). New helpers:getOwnStyleValue()— reads dash-case/camelCase spellings fromelement.style, then from the parsed rawstyleattributeparseInlineStyle()— safely parses the rawstyleattribute (never throws)This also covers the React case (
style={{aspectRatio}}), which sets the property via direct expando assignment.Tests
src/__tests__/to-have-style.js: aspect-ratio via style attribute (string + object forms, incl. negative wrong-value cases) and via direct style assignment (dash-case + camelCase keys)to-have-stylesuite: 15/15 pass (13 existing + 2 new)