Bug 40578 - insertRule throws exception for @namespace
Summary: insertRule throws exception for @namespace
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://pastie.org/1003535
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2010-06-14 11:15 PDT by Jos van den Oever
Modified: 2022-07-11 17:17 PDT (History)
5 users (show)

See Also:


Attachments
html with javascript that calls insertRule (612 bytes, text/xml)
2010-06-14 11:15 PDT, Jos van den Oever
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jos van den Oever 2010-06-14 11:15:53 PDT
Created attachment 58673 [details]
html with javascript that calls insertRule

Programmatically building a stylesheet is currently not possible since the insertRule function throws and exception if a rule is added that contains an '@'.

This works fine in Firefox 3.6.3. 

http://www.w3.org/TR/DOM-Level-2-Style/css.html


<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>CSS: insertRule with @namespace gives exception</title>
  <style type="text/css" id='css'>
  </style>
  <script type="text/javascript" charset="utf-8">
function init() {
  var stylesheet = document.getElementById('css').sheet;
  stylesheet.insertRule(
     '@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0)',
     stylesheet.cssRules.length);
  document.getElementById('body').innerHTML = 'Call to insertRule was ok.';
}
  </script>
 </head>
 <body onload='init()' id='body'>
   insertRule has not been called yet.
 </body>
</html>
Comment 1 Jos van den Oever 2010-06-14 11:32:36 PDT
The problem in the snippet below. For some reason, namespacedeclarations are not allowed.

WebCore/css/CSSParser.cpp:245
PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
{
    m_styleSheet = sheet;
    m_allowNamespaceDeclarations = false;
    setupParser("@-webkit-rule{", string, "} ");
    cssyyparse(this);
    return m_rule.release();
}
Comment 2 Alexey Proskuryakov 2010-06-14 16:39:06 PDT
This line was added in <http://trac.webkit.org/changeset/51608>, but the test failed before that (it fails for me in Safari 4.0.5).
Comment 3 Brent Fulgham 2022-07-11 17:16:39 PDT
Safari, Chrome, and Firefox show the same rendering behavior for this test case. I do not believe any further compatibility issue remains.
Comment 4 Radar WebKit Bug Importer 2022-07-11 17:17:15 PDT
<rdar://problem/96851904>