-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement getComputedStyle() for font-family (#3614) #3615
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -92,6 +92,12 @@ exports.propertiesWithResolvedValueImplemented = { | |||||||||||||||||||||||||||||||||||||||||||||||||
inherited: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||
initial: "invert", | ||||||||||||||||||||||||||||||||||||||||||||||||||
computedValue: "computed-color" | ||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
// https://drafts.csswg.org/css-fonts-4/#font-family-prop | ||||||||||||||||||||||||||||||||||||||||||||||||||
"font-family": { | ||||||||||||||||||||||||||||||||||||||||||||||||||
inherited: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
initial: "", | ||||||||||||||||||||||||||||||||||||||||||||||||||
computedValue: "as-specified" | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't appear correct. Per spec it's The appropriate test to add is something like <div style="font-family: serif,sans-serif, 'Times New Roman',Arial"></div> and then testing that the computed style is Making that work correctly would involve introducing some new infrastructure, probably around here? jsdom/lib/jsdom/living/helpers/style-rules.js Lines 214 to 237 in 907daec
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Computed fontFamily is inherited</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<style> | ||
#parent { | ||
pointer-events: none; | ||
} | ||
</style> | ||
|
||
<body> | ||
<div id="parent" style="font-family: Arial;"> | ||
<div id="child">Child</div> | ||
</div> | ||
</body> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
test(() => { | ||
const parent = window.document.querySelector("#parent"); | ||
assert_equals(getComputedStyle(parent).fontFamily, "Arial"); | ||
}, "Parent element returns the directly specified value for fontFamily"); | ||
|
||
test(() => { | ||
const child = document.querySelector("#child"); | ||
assert_equals(getComputedStyle(child).fontFamily, "Arial"); | ||
}, "Child element inherits the fontFamily value from its parent"); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this needs to be set to something like
"serif"
. Can you do that, and then update the test? https://jsbin.com/tulemoreka/edit?html,output