Open Bug 1543139 Opened 7 years ago Updated 3 years ago

Remove type="text/css" on <style> and <link> elements, and <xml-stylesheet> PIs in tree

Categories

(Core :: CSS Parsing and Computation, task, P3)

task

Tracking

()

People

(Reporter: bgrins, Unassigned)

References

Details

Attachments

(1 obsolete file)

+++ This bug was initially created as a clone of Bug #1542877 +++

This is another thing we could do to tighten up test boilerplate. See https://groups.google.com/d/msg/mozilla.dev.platform/2cDuT_sNZ-o/V4w-zBhCCQAJ.

Cam, to confirm: this would only apply to <style> tags and not <?xml-stylesheet> or <link rel="stylesheet">, correct?

Flags: needinfo?(cam)
Type: defect → task

It should also apply to <link rel="stylesheet">. Not 100% sure about xml-stylesheets, but probably too.

As Emilio says, <link> defaults to type="text/css" if rel="stylesheet".

xml-stylesheet PIs have the same behavior. See https://searchfox.org/mozilla-central/source/dom/xml/XMLStylesheetProcessingInstruction.cpp#119 where an empty type is treated the same as "text/css".

Or for an experimental testcase:

data:text/xml,<?xml-stylesheet href="data:text/css,* { color: red }"?><root>text</root>

Flags: needinfo?(cam)

Thanks! Updating the title to reflect this.

Summary: Remove type="text/css" on <style> elements in tree → Remove type="text/css" on <style> and <link> elements, and <xml-stylesheet> PIs in tree

If you are looking for a linter, this outputs "true" if there is a type attribute on the wrong thing.

xmllint --html --xpath '//link[@rel="stylesheet"]/@type or //style/@type' index.html 2>/dev/null

It shouldn't be too hard to add a selector for the PI to that.

Depends on: 1543841
Severity: normal → S3
Attachment #9057168 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: