@@ -135,48 +135,20 @@ export class DominoAdapter extends BrowserDomAdapter {
135135 return href ;
136136 }
137137
138- /** @internal */
139- _readStyleAttribute ( element : any ) {
140- const styleMap = { } ;
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- if ( styleList [ i ] . length > 0 ) {
146- const style = styleList [ i ] as string ;
147- const colon = style . indexOf ( ':' ) ;
148- if ( colon === - 1 ) {
149- throw new Error ( `Invalid CSS style: ${ style } ` ) ;
150- }
151- ( styleMap as any ) [ style . substr ( 0 , colon ) . trim ( ) ] = style . substr ( colon + 1 ) . trim ( ) ;
152- }
153- }
154- }
155- return styleMap ;
156- }
157- /** @internal */
158- _writeStyleAttribute ( element : any , styleMap : any ) {
159- let styleAttrValue = '' ;
160- for ( const key in styleMap ) {
161- const newValue = styleMap [ key ] ;
162- if ( newValue ) {
163- styleAttrValue += key + ':' + styleMap [ key ] + ';' ;
164- }
165- }
166- element . setAttribute ( 'style' , styleAttrValue ) ;
167- }
168138 setStyle ( element : any , styleName : string , styleValue ?: string | null ) {
169- const styleMap = this . _readStyleAttribute ( element ) ;
170- ( styleMap as any ) [ styleName ] = styleValue ;
171- this . _writeStyleAttribute ( element , styleMap ) ;
139+ styleName = styleName . replace ( / ( [ a - z ] ) ( [ A - Z ] ) / g, '$1-$2' ) . toLowerCase ( ) ;
140+ element . style [ styleName ] = styleValue ;
141+ }
142+ removeStyle ( element : any , styleName : string ) {
143+ // IE requires '' instead of null
144+ // see https://github.com/angular/angular/issues/7916
145+ element . style [ styleName ] = '' ;
172146 }
173- removeStyle ( element : any , styleName : string ) { this . setStyle ( element , styleName , null ) ; }
174147 getStyle ( element : any , styleName : string ) : string {
175- const styleMap = this . _readStyleAttribute ( element ) ;
176- return styleMap . hasOwnProperty ( styleName ) ? ( styleMap as any ) [ styleName ] : '' ;
148+ return element . style [ styleName ] || element . style . getPropertyValue ( styleName ) ;
177149 }
178150 hasStyle ( element : any , styleName : string , styleValue ?: string ) : boolean {
179- const value = this . getStyle ( element , styleName ) || '' ;
151+ const value = this . getStyle ( element , styleName ) ;
180152 return styleValue ? value == styleValue : value . length > 0 ;
181153 }
182154
@@ -206,4 +178,4 @@ export class DominoAdapter extends BrowserDomAdapter {
206178 supportsCookies ( ) : boolean { return false ; }
207179 getCookie ( name : string ) : string { throw _notImplemented ( 'getCookie' ) ; }
208180 setCookie ( name : string , value : string ) { throw _notImplemented ( 'setCookie' ) ; }
209- }
181+ }
0 commit comments