Closed Bug 605157 Opened 15 years ago Closed 15 years ago

Style tags are ignored in innerHTML in XML

Categories

(Core :: XML, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla2.0b7
Tracking Status
blocking2.0 --- final+

People

(Reporter: lorchard, Assigned: bzbarsky)

References

Details

Attachments

(1 file, 2 obsolete files)

Filing this bug from the discussion in bug 592431. The original issue was that I couldn't get CSS in <style> elements to take effect.
Attaching a patch that seems to fix the problem for me, but also switches the snippet loading process from using innerHTML to the importNode DOM method. Not sure if that's what should be done or not, but it seems to fix the problem.
Component: General → XML
Priority: -- → P1
Product: Firefox → Core
QA Contact: general → xml
Summary: Style tags are ignored in about:home snippets → Style tags are ignored in innerHTML in XML
Comment on attachment 484023 [details] [diff] [review] Style linking elements should work in XML when set via innerHTML. I could also hack this in the fragment sink, but this seems like the right thing to me. The only question is whether the SetLineNumber thing should also be if aFromParser.
Attachment #484023 - Flags: review?(jonas)
Whiteboard: [need review]
Possibly related to this is bug 594989 - that is, JS in <script> tags from HTML injected via innerHTML are also ignored. Is that also a bug?
Actually, we are not setting innerHTML to document.head like in the reftest here but in a div in body, is that what we should do instead? (so after innerHTLM just remove the <style> from body and add it to head?) Our case is more like document.getElementById("some_div").innerHTML = "<span id="some_span>test</span><style>#some_span { color: green; }</style>";
Yeah, I suspect setting the initial line number to 0 is the best thing we can do when parsing a fragment.
> JS in <script> tags from HTML injected via innerHTML are also ignored. That's required by both web compat and the HTML5 spec. > is that what we should do instead? Doesn't matter; I just did it that way in the reftest because it let me use a minimal number of tags. > I suspect setting the initial line number to 0 is the best thing we can do Sure; but do you want to do that explicitly, or assume that the fragment parser is already handling that?
ccing sicking, so he'll see comment 7.
Can't aLineNumber be != 0 during fragment parsing there? I.e. won't it be the line number within the fragment? If it's always 0 I don't really care much, especially if we have a test.
Comment on attachment 484023 [details] [diff] [review] Style linking elements should work in XML when set via innerHTML. r=me if you either include a test, or explicitly do SetLineNumber(aFromParser ? aLineNumber : 0) (don't know how hard it is to test the set line number from the page)
Attachment #484023 - Flags: review?(jonas) → review+
> (don't know how hard it is to test the set line number from the page) Impossible, modulo use of UniversalXPConnect. I can do the explicit set to 0, or I do what the html fragment sink does and not set at all (defaults to 1). Preferences?
Attachment #483996 - Attachment is obsolete: true
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Whiteboard: [need review] → [needs updated patch]
Attachment #484023 - Attachment is obsolete: true
Whiteboard: [needs updated patch] → [needs landing]
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Target Milestone: --- → mozilla2.0b8
Target Milestone: mozilla2.0b8 → mozilla2.0b7
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: