@@ -135,17 +135,51 @@ export class DominoAdapter extends BrowserDomAdapter {
135135 return href ;
136136 }
137137
138+ /** @internal */
139+ _readStyleAttribute ( element : any ) : { [ name : string ] : string } {
140+ const styleMap : { [ name : string ] : string } = { } ;
141+ const styleAttribute = element . getAttribute ( 'style' ) ;
142+ if ( styleAttribute ) {
143+ const styleList = styleAttribute . split ( / ; + / g) ;
144+ for ( let i = 0 ; i < styleList . length ; i ++ ) {
145+ const style = styleList [ i ] . trim ( ) ;
146+ if ( style . length > 0 ) {
147+ const colonIndex = style . indexOf ( ':' ) ;
148+ if ( colonIndex === - 1 ) {
149+ throw new Error ( `Invalid CSS style: ${ style } ` ) ;
150+ }
151+ const name = style . substr ( 0 , colonIndex ) . trim ( ) ;
152+ styleMap [ name ] = style . substr ( colonIndex + 1 ) . trim ( ) ;
153+ }
154+ }
155+ }
156+ return styleMap ;
157+ }
158+ /** @internal */
159+ _writeStyleAttribute ( element : any , styleMap : { [ name : string ] : string } ) {
160+ let styleAttrValue = '' ;
161+ for ( const key in styleMap ) {
162+ const newValue = styleMap [ key ] ;
163+ if ( newValue ) {
164+ styleAttrValue += key + ':' + styleMap [ key ] + ';' ;
165+ }
166+ }
167+ element . setAttribute ( 'style' , styleAttrValue ) ;
168+ }
138169 setStyle ( element : any , styleName : string , styleValue ?: string | null ) {
139170 styleName = styleName . replace ( / ( [ a - z ] ) ( [ A - Z ] ) / g, '$1-$2' ) . toLowerCase ( ) ;
140- element . style [ styleName ] = styleValue ;
171+ const styleMap = this . _readStyleAttribute ( element ) ;
172+ styleMap [ styleName ] = styleValue || '' ;
173+ this . _writeStyleAttribute ( element , styleMap ) ;
141174 }
142175 removeStyle ( element : any , styleName : string ) {
143176 // IE requires '' instead of null
144177 // see https://github.com/angular/angular/issues/7916
145- element . style [ styleName ] = '' ;
178+ this . setStyle ( element , styleName , '' ) ;
146179 }
147180 getStyle ( element : any , styleName : string ) : string {
148- return element . style [ styleName ] || element . style . getPropertyValue ( styleName ) ;
181+ const styleMap = this . _readStyleAttribute ( element ) ;
182+ return styleMap [ styleName ] || '' ;
149183 }
150184 hasStyle ( element : any , styleName : string , styleValue ?: string ) : boolean {
151185 const value = this . getStyle ( element , styleName ) ;
0 commit comments