Commit 6faa5f2 1 parent c7b07c6 commit 6faa5f2 Copy full SHA for 6faa5f2
File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export class MockCSSStyleDeclaration {
47
47
const splt = rule . split ( ':' ) ;
48
48
if ( splt . length > 1 ) {
49
49
const prop = splt [ 0 ] . trim ( ) ;
50
- const value = splt [ 1 ] . trim ( ) ;
50
+ const value = splt . slice ( 1 ) . join ( ':' ) . trim ( ) ;
51
51
if ( prop !== '' && value !== '' ) {
52
52
this . _styles . set ( jsCaseToCssCase ( prop ) , value ) ;
53
53
}
Original file line number Diff line number Diff line change
1
+ import { MockCSSStyleDeclaration } from '../css-style-declaration' ;
2
+ import { MockDocument } from '../document' ;
3
+ import { MockHTMLElement } from '../node' ;
4
+
5
+ describe ( 'css-style-declaration' , ( ) => {
6
+ let doc : MockDocument ;
7
+ beforeEach ( ( ) => {
8
+ doc = new MockDocument ( ) ;
9
+ } ) ;
10
+
11
+ it ( 'should set attributes correctly' , ( ) => {
12
+ const cssAttr = new MockCSSStyleDeclaration ( ) ;
13
+ cssAttr . cssText = 'color: red' ;
14
+
15
+ expect ( cssAttr . cssText ) . toBe ( 'color: red;' ) ;
16
+ } ) ;
17
+
18
+ it ( 'should handle attributes containing colons' , ( ) => {
19
+ const cssAttr = new MockCSSStyleDeclaration ( ) ;
20
+ cssAttr . cssText = 'background-image: (https://ionic.io/img/ionic-io-og-img.png);' ;
21
+
22
+ expect ( cssAttr . cssText ) . toBe ( 'background-image: (https://ionic.io/img/ionic-io-og-img.png);' ) ;
23
+ } ) ;
24
+
25
+ it ( 'should set styles on html elements' , ( ) => {
26
+ const element = new MockHTMLElement ( doc , 'div' ) ;
27
+ element . style = 'color: red; font-family: "My Custom Font"' ;
28
+
29
+ expect ( element . style . cssText ) . toEqual ( 'color: red; font-family: "My Custom Font";' ) ;
30
+ expect ( element . style . cssText ) . toEqual ( element . getAttribute ( 'style' ) ) ;
31
+ } ) ;
32
+ } ) ;
You can’t perform that action at this time.
0 commit comments