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>
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(); }
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).
Safari, Chrome, and Firefox show the same rendering behavior for this test case. I do not believe any further compatibility issue remains.
<rdar://problem/96851904>