@@ -35,7 +35,7 @@ export type NgClassType = string | string[] | Set<string> | {[klass: string]: an
35
35
*/
36
36
@Directive ( {
37
37
selector : `
38
- [class], [class .xs], [class.sm], [class.md], [class.lg], [class.xl],
38
+ [class.xs], [class.sm], [class.md], [class.lg], [class.xl],
39
39
[class.lt-sm], [class.lt-md], [class.lt-lg], [class.lt-xl],
40
40
[class.gt-xs], [class.gt-sm], [class.gt-md], [class.gt-lg],
41
41
@@ -77,18 +77,6 @@ export class ClassDirective extends BaseFxDirective
77
77
78
78
/** Deprecated selectors */
79
79
80
- /**
81
- * Base class selector values get applied immediately and are considered destructive overwrites to
82
- * all previous class assignments
83
- *
84
- * Delegate to NgClass:klass setter and cache value for base fallback from responsive APIs.
85
- */
86
- @Input ( 'class' )
87
- set classBase ( val : string ) {
88
- this . _classAdapter . cacheInput ( '_rawClass' , val , true ) ;
89
- this . _ngClassInstance . klass = val ;
90
- }
91
-
92
80
@Input ( 'class.xs' ) set classXs ( val : NgClassType ) { this . _classAdapter . cacheInput ( 'classXs' , val , true ) ; }
93
81
@Input ( 'class.sm' ) set classSm ( val : NgClassType ) { this . _classAdapter . cacheInput ( 'classSm' , val , true ) ; }
94
82
@Input ( 'class.md' ) set classMd ( val : NgClassType ) { this . _classAdapter . cacheInput ( 'classMd' , val , true ) ; }
@@ -105,14 +93,6 @@ export class ClassDirective extends BaseFxDirective
105
93
@Input ( 'class.gt-md' ) set classGtMd ( val : NgClassType ) { this . _classAdapter . cacheInput ( 'classGtMd' , val , true ) ; }
106
94
@Input ( 'class.gt-lg' ) set classGtLg ( val : NgClassType ) { this . _classAdapter . cacheInput ( 'classGtLg' , val , true ) ; }
107
95
108
- /**
109
- * Initial value of the `class` attribute; used as
110
- * fallback and will be merged with nay `ngClass` values
111
- */
112
- get initialClasses ( ) : string {
113
- return this . _classAdapter . queryInput ( '_rawClass' ) || "" ;
114
- }
115
-
116
96
/* tslint:enable */
117
97
constructor ( protected monitor : MediaMonitor ,
118
98
_ngEl : ElementRef , _renderer : Renderer2 , _oldRenderer : Renderer ,
@@ -121,8 +101,9 @@ export class ClassDirective extends BaseFxDirective
121
101
122
102
super ( monitor , _ngEl , _renderer ) ;
123
103
124
- this . _classAdapter = new BaseFxDirectiveAdapter ( 'class' , monitor , _ngEl , _renderer ) ;
125
104
this . _ngClassAdapter = new BaseFxDirectiveAdapter ( 'ngClass' , monitor , _ngEl , _renderer ) ;
105
+ this . _classAdapter = new BaseFxDirectiveAdapter ( 'class' , monitor , _ngEl , _renderer ) ;
106
+ this . _classAdapter . cacheInput ( 'class' , _ngEl . nativeElement . getAttribute ( 'class' ) || '' , true ) ;
126
107
127
108
// Create an instance NgClass Directive instance only if `ngClass=""` has NOT been defined on
128
109
// the same host element; since the responsive variations may be defined...
@@ -156,7 +137,9 @@ export class ClassDirective extends BaseFxDirective
156
137
if ( ! this . _classAdapter . hasMediaQueryListener ) {
157
138
this . _configureMQListener ( ) ;
158
139
}
159
- this . _ngClassInstance . ngDoCheck ( ) ;
140
+ if ( this . _ngClassInstance ) {
141
+ this . _ngClassInstance . ngDoCheck ( ) ;
142
+ }
160
143
}
161
144
162
145
ngOnDestroy ( ) {
@@ -174,11 +157,12 @@ export class ClassDirective extends BaseFxDirective
174
157
* mql change events to onMediaQueryChange handlers
175
158
*/
176
159
protected _configureMQListener ( ) {
177
- this . _classAdapter . listenForMediaQueryChanges ( 'class' , '' , ( changes : MediaChange ) => {
160
+ const value = this . _classAdapter . queryInput ( 'class' ) ;
161
+ this . _classAdapter . listenForMediaQueryChanges ( 'class' , value , ( changes : MediaChange ) => {
178
162
this . _updateKlass ( changes . value ) ;
179
163
} ) ;
180
164
181
- this . _ngClassAdapter . listenForMediaQueryChanges ( 'ngClass' , '' , ( changes : MediaChange ) => {
165
+ this . _ngClassAdapter . listenForMediaQueryChanges ( 'ngClass' , value , ( changes : MediaChange ) => {
182
166
this . _updateNgClass ( changes . value ) ;
183
167
this . _ngClassInstance . ngDoCheck ( ) ; // trigger NgClass::_applyIterableChanges()
184
168
} ) ;
@@ -189,11 +173,11 @@ export class ClassDirective extends BaseFxDirective
189
173
* ::ngDoCheck() is not needed
190
174
*/
191
175
protected _updateKlass ( value ?: NgClassType ) {
192
- let klass = value || this . _classAdapter . queryInput ( 'class' ) || '' ;
176
+ let klass = value || this . _classAdapter . queryInput ( 'class' ) ;
193
177
if ( this . _classAdapter . mqActivation ) {
194
178
klass = this . _classAdapter . mqActivation . activatedInput ;
195
179
}
196
- this . _ngClassInstance . klass = klass || this . initialClasses ;
180
+ this . _ngClassInstance . klass = klass ;
197
181
}
198
182
199
183
/**
0 commit comments