Closed Bug 1594241 Opened 4 years ago Closed 4 years ago

CSSOM cssText property is missing styles from stylesheet

Categories

(Core :: DOM: CSS Object Model, defect, P3)

69 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: probablyup, Assigned: nordzilla, Mentored)

Details

(Keywords: good-first-bug, Whiteboard: [lang=rust], [wptsync upstream])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36

Steps to reproduce:

  1. Go to a page and create a style element in head with this content:

<style id="style-test">
.a{border:none;font-size:36px;border-image:linear-gradient(315deg,#fff8c5,#fdb3e4);border-width:3px;border-style:solid;border-image-slice:1;background-color:white;}
</style>

  1. Go to your console and inspect it:

document.getElementById("style-test").sheet.cssRules[0]

  1. Notice that .cssText is missing the border-image declaration, but if you access the style property it's actually there:

document.getElementById("style-test").sheet.cssRules[0].style['border-image']

Actual results:

.cssText returns this:

.a { border: 3px solid; font-size: 36px; background-color: white; }

Expected results:

.cssText should return:

.a { border: none; font-size: 36px; border-image: linear-gradient(315deg, #fff8c5, #fdb3e4); border-width: 3px; border-style: solid; border-image-slice: 1; background-color: white; }

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core

Yeah, this is clearly a bug.

The border shorthand always resets border-image, etc, to its initial value: https://searchfox.org/mozilla-central/rev/8b7aa8af652f87d39349067a5bc9c0256bf6dedc/servo/components/style/properties/shorthands/border.mako.rs#147

But it doesn't check whether those properties are initial when serializing back: https://searchfox.org/mozilla-central/rev/8b7aa8af652f87d39349067a5bc9c0256bf6dedc/servo/components/style/properties/shorthands/border.mako.rs#182

Should be a pretty easy bug to fix, we effectively need to add a check like:

% for name in "outset repeat slice source width".split():
if self.border_image_${name} != border_image_${name}::get_initial_specified_value() {
    return Ok(());
}
% endfor

Somewhere around here.

And add a regression test if there's none of course.

Mentor: emilio
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: good-first-bug
Priority: -- → P3
Whiteboard: [lang=rust]
Assignee: nobody → enordin
Attachment #9113089 - Attachment description: Bug 1594241 - Check for border-image-* initial specified values when serializing border shorthand → Bug 1594241 - Check for border-image-* initial specified values when serializing border shorthand r=emilio,boris
Pushed by btara@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e31cda624e1b
Check for border-image-* initial specified values when serializing border shorthand r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/20590 for changes under testing/web-platform/tests
Whiteboard: [lang=rust] → [lang=rust], [wptsync upstream]
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
Upstream PR was closed without merging
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.