On Wed, 24 Jun 2015 00:47:01 +0200, Philip Jägenstedt <
phi...@opera.com>
wrote:
> The API owners met today to discuss this. CSSOM editor Simon is on
> parental
> leave, but these are the questions we would have asked:
>
> Is there a concrete use case for exposing this, or is it "just" a matter
> of
> all supported rules in the syntax (except @charset) also having a
> corresponding CSS*Rule interface?
Mostly the latter, in my opinion. But I also think it should be possible
to build a stylesheet with @namespace with the API (using insertRule()),
instead of having to set textContent (which would mean reparsing the full
stylesheet each time you add to it).
> (It looks like having the CSSNamespaceRule exposed is actually required
> to
> interpret which elements selectors in other rules will match, which seems
> like an unfortunate API. Namespaces are weird in DOM too, but at least
> there it's possible to just check the namespace of a node without doing
> the
> prefix mapping manually.)
The mapping is only done when parsing or inserting a rule, but yeah.
> Also, is there any use in making namespaceURI and prefix mutable? I wrote
> an ad-hoc test
> <
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3549>, and
> it
> looks like setting has no effect in IE, and the namespaceURI and prefix
> attributes aren't even supported in Firefox.
Per spec it is only mutable if there aren't any other rules in the
stylesheet that they would affect. The rationale is that if you wanted to
change the prefix, you would have to remove the @namespace rule and insert
a new one, instead of just setting .prefix.
([RaisesException] is not a standard extended attribute in WebIDL.)
> 2) If we implement as per the above spec, if we want to change the
> @namespace rule attributes dynamically after some rules were added, we
> will
> never be able to change.
> For ex: In the below example prefix value cannot be changed, since the
> StyleRule is already present in addition to namespace rule, in parent
> stylesheet. Is this intended behavior as per spec?
>
> <!DOCTYPE html>
> <style>
> @namespace html-namespace url(
http://www.w3.org/1999/xhtml);
> html-namespace|body {
> color: red;
> }
> </style>
> <script>
> var body = document.body,
> firstRule = document.styleSheets[0].cssRules[0];
> firstRule.prefix = "mywish";
> alert(firstRule.prefix);
> </script>
Yes, this would throw per spec to avoid having to redo the namespace
mapping of all the rules.
> 3)Have one doubt w.r.t testcase in
>
https://code.google.com/p/chromium/issues/detail?id=389549.
> typeof CSSNamespaceRule === 'object') returns true in IE. In chrome if we
> implement this spec it shows as 'function'. Also even for other rules
> like
> CSSMediaRule type is shown as 'function'.
> Is this expected behavior?
IIRC "function" is expected per WebIDL.
On Wed, 24 Jun 2015 07:04:21 +0200, Elliott Sprehn <
esp...@chromium.org>
wrote:
> Changing this means reparsing the sheet, I'm not sure we should support
> that and it's of very dubious value since we don't ever plan to add more
> namespace oriented features.
>
> Can we get this made read-only instead?
I think you misunderstood, the spec only allows mutation of @namespace if
the stylesheet doesn't contain any rules that would be affected (so you
would never reparse the stylesheet or redo namespace mappings). But I'm
happy to change back to readonly if it's more confusing than helpful.
On Wed, 24 Jun 2015 21:55:54 +0200, Elliott Sprehn <
esp...@chromium.org>
wrote:
> The sane thing is that the constructor takes the parameters and the
> properties are read only. I don't think we want to this mutable but
> throws
> behavior.
>
> var rule = new CSSNamespaceRule("prefix", "url");
CSSOM doesn't have such constructors yet, but a string-based API. A less
sucky API with constructors etc is planned but not there yet, and the
legacy API isn't going away.
HTH,
--
Simon Pieters
Opera Software