Closed Bug 1712623 Opened 3 years ago Closed 2 years ago

Add disabled property to SVGStyleElement

Categories

(Core :: SVG, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: longsonr, Assigned: longsonr)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

Chrome supports this: https://github.com/chromium/chromium/blob/d7da0240cae77824d1eda25745c4022757499131/third_party/blink/renderer/core/svg/svg_style_element.idl#L42 The comment there is old i.e. prior to emilio's disabled rewrite in bug 1281135 I think.

It's consistent with the specification's desire to align SVG and HTML style elements per https://www.w3.org/TR/SVG2/styling.html#StyleElement

And users want it per https://stackoverflow.com/questions/66785148/can-a-svgstyleelement-be-disabled-like-an-htmlstyleelement-can

consistent with Chrome, the desires of the specification

Assignee: nobody → longsonr
Status: NEW → ASSIGNED

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:longsonr, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(longsonr)
Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Flags: needinfo?(longsonr)
Pushed by longsonr@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/a36d2a126866
add disabled property to SVGStyleElement r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/34630 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
Upstream PR merged by moz-wptsync-bot

FYI FF104 docs work for this can be tracked in https://github.com/mdn/content/issues/18775

Hi Robert,

Some questions around SVGStyleElement, including to do with disabled (docs for the page in poor form currently so I want to make sure we cover everything).

  1. Based on your answer here, I have attached some test code for SVGStyleElement here that logs the media, type, disabled, sheet properties. What this appears to show is that FF does not support media or type properties in the same way. Can you explain why?

  2. The subset of your code in which disables might be set is shown below. This makes sense - you first create an element of the svg namespace, which is what tells the user agent you're after an SVGStyleElement, then you create some style information and add it to that element. The disabled only works once you have added the stylesheet information to the node.

     const svg = document.getElementsByTagName("svg")[0];
     const style = document.createElementNS('http://www.w3.org/2000/svg', 'style');
     const node = document.createTextNode('circle { fill: red; }');
    
     svg.appendChild(style);
     style.disabled=true;  //Won't work!
     style.appendChild(node);
     // style.disabled=true;  //Will work if not commented
    

    It is inline with the spec that there must be a stylesheet or setting disabled = true has no effect. However how then should you add a stylesheet "initially disabled"? (I'd kind of assumed the first case would work - and "empty stylesheet" not being the same as "no stylesheet".

  3. HTMLStyleElement.type is marked as deprecated in MDN docs. Is the same thing true for SVGStyleElement? The spec seems to indicate the default value but not other values that might be supplied - what might they be?

Flags: needinfo?(longsonr)

1, 2, 3 SVG style elements work the same as for HTML style elements.

Flags: needinfo?(longsonr)
You need to log in before you can comment on or make changes to this bug.