Skip to content

Commit cbecbce

Browse files
devversionjelbourn
authored andcommitted
fix(slide-toggle): remove view encapsulation (#1446)
* fix(slide-toggle): remove view encapsulation * Removes the ViewEncapsulation from the slide-toggle component to allow developer overwriting the styles easly. Fixes #1343. * Make _hasFocus variable public again for AOT compiler
1 parent bfee9c3 commit cbecbce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib/slide-toggle/slide-toggle.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $md-slide-toggle-margin: 16px !default;
1616
@include md-temporary-ink-ripple(slide-toggle, true);
1717
}
1818

19-
:host {
19+
md-slide-toggle {
2020
display: flex;
2121
height: $md-slide-toggle-height;
2222

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
AfterContentInit,
1111
NgModule,
1212
ModuleWithProviders,
13+
ViewEncapsulation,
1314
} from '@angular/core';
1415
import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
1516
import {
@@ -50,6 +51,7 @@ let nextId = 0;
5051
templateUrl: 'slide-toggle.html',
5152
styleUrls: ['slide-toggle.css'],
5253
providers: [MD_SLIDE_TOGGLE_VALUE_ACCESSOR],
54+
encapsulation: ViewEncapsulation.None,
5355
changeDetection: ChangeDetectionStrategy.OnPush
5456
})
5557
export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
@@ -61,10 +63,12 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
6163
private _uniqueId = `md-slide-toggle-${++nextId}`;
6264
private _checked: boolean = false;
6365
private _color: string;
64-
_hasFocus: boolean = false;
6566
private _isMousedown: boolean = false;
6667
private _slideRenderer: SlideToggleRenderer = null;
6768

69+
// Needs to be public to support AOT compilation (as host binding).
70+
_hasFocus: boolean = false;
71+
6872
@Input() @BooleanFieldValue() disabled: boolean = false;
6973
@Input() @BooleanFieldValue() required: boolean = false;
7074
@Input() name: string = null;

0 commit comments

Comments
 (0)