Skip to content

[cssom-1] Serializing via cssText doesn't give url(<string>) #9913

Open
@gsnedders

Description

@gsnedders

From https://bugs.webkit.org/show_bug.cgi?id=268742:

const style = document.createElement('style')
document.body.append(style)
style.sheet.insertRule(`h6 {
    background: url(/my-image.png), var(--my-image);
}`)
console.log(style.sheet.cssRules[0].cssText)

Safari outputs:

h6 { background: url(\/my-image\.png), var(--my-image); }

Chrome and Firefox outputs:

h6 { background: url(/my-image.png), var(--my-image); }

Per spec, cssText returns "a serialization of the CSS rule".

A URL is serialized as '"url(", followed by the serialization of the URL as a string, followed by ")"', which implies the above should be url("/my-image.png"), contrary to all major browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions