4 <title>CSSOM - CSSStyleDeclaration - Text - Serialization - Delimiters
</title>
5 <link rel=
"author" title=
"Glenn Adams" href=
"mailto:glenn@skynav.com"/>
6 <link rel=
"help" href=
"http://www.w3.org/TR/cssom/#the-cssstyledeclaration-interface"/>
7 <meta name=
"flags" content=
"dom"/>
8 <script src=
"../resources/testharness.js"></script>
9 <script src=
"../resources/testharnessreport.js"></script>
15 var style
= document
.getElementById('box').style
;
16 var delim
= new RegExp ( /(\s*\;\s*)/ );
18 function countDelimiters(s
) {
19 var k
= ( s
.split(delim
).length
- 1 ) / 2;
23 function getNthDelimiter(s
,n
) {
25 var sa
= s
.split(delim
);
29 var m
= delim
.exec(s
);
30 if ( m
&& ( m
.length
> 1 ) ) {
43 assert_equals(countDelimiters(style
.cssText
), 0);
44 assert_equals(getNthDelimiter(style
.cssText
,0), "");
45 assert_equals(style
.cssText
, "");
47 }, 'inline style - text - delimiters - zero declarations');
51 style
.cssText
= "left: 10px";
52 assert_equals(countDelimiters(style
.cssText
), 1);
53 assert_equals(getNthDelimiter(style
.cssText
,1), ";");
54 assert_equals(style
.cssText
, "left: 10px;");
56 }, 'inline style - text - delimiters - one declaration');
60 style
.cssText
= "left: 10px; right: 20px";
61 assert_equals(countDelimiters(style
.cssText
), 2);
62 assert_equals(getNthDelimiter(style
.cssText
,1), "; ");
63 assert_equals(getNthDelimiter(style
.cssText
,2), ";");
64 assert_equals(style
.cssText
, "left: 10px; right: 20px;");
66 }, 'inline style - text - delimiters - two declarations');