W3C DOM tests - styleSheet tests

This is element x. It has inline style border: 1px solid #cc0000. Element y is the test style sheet.

Element z is the special <style> block in this page, which contains a color declaration with !important and a normal font-size declaration.

Test scripts

createStyleSheet

This style sheet adds a font-size: 130%; to element x.

document.createStyleSheet('teststyleSheet2.css');

getPropertyPriority

alert(z.cssRules[0].style.getPropertyPriority('color'))
alert(z.cssRules[0].style.getPropertyPriority('font-size'))

And for IE.

alert(z.rules[0].style.getPropertyPriority('color'))
alert(z.rules[0].style.getPropertyPriority('font-size'))

getPropertyValue

alert(z.cssRules[0].style.getPropertyValue('color'))
alert(z.cssRules[0].style.getPropertyValue('font-size'))

And for IE.

alert(z.rules[0].style.getPropertyValue('color'))
alert(z.rules[0].style.getPropertyValue('font-size'))

ownerNode

alert(y.ownerNode.nodeName)
alert(z.ownerNode.nodeName)

parentStyleSheet

alert(y.cssRules[0].parentStyleSheet)
alert(z.cssRules[0].parentStyleSheet)

And for IE.

alert(y.rules[0].parentStyleSheet)
alert(z.rules[0].parentStyleSheet)

removeProperty

y.cssRules[y.cssRules.length-1].style.removeProperty('color');

And for IE.

y.rules[y.rules.length-1].style.removeProperty('color');

setProperty

y.cssRules[y.cssRules.length-1].style.setProperty('font-size','130%',null);

And for IE.

y.rules[y.rules.length-1].style.setProperty('font-size','130%',null);