Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cdk/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
IterableDiffers,
SimpleChanges,
TemplateRef,
ViewContainerRef
ViewContainerRef,
ViewEncapsulation,
} from '@angular/core';
import {CdkCellDef} from './cell';

Expand Down Expand Up @@ -147,6 +148,7 @@ export class CdkCellOutlet {
'role': 'row',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class CdkHeaderRow { }

Expand All @@ -159,5 +161,6 @@ export class CdkHeaderRow { }
'role': 'row',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class CdkRow { }
1 change: 1 addition & 0 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class MdDatepickerContent<D> implements AfterContentInit {
selector: 'md-datepicker, mat-datepicker',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdDatepicker<D> implements OnDestroy {
/** The date to open the calendar to initially. */
Expand Down
1 change: 1 addition & 0 deletions src/lib/grid-list/grid-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class MdGridTile {
selector: 'md-grid-tile-header, mat-grid-tile-header, md-grid-tile-footer, mat-grid-tile-footer',
templateUrl: 'grid-tile-text.html',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdGridTileText implements AfterContentInit {
/**
Expand Down
9 changes: 8 additions & 1 deletion src/lib/menu/menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Component, ElementRef, OnDestroy, ChangeDetectionStrategy} from '@angular/core';
import {
Component,
ElementRef,
OnDestroy,
ChangeDetectionStrategy,
ViewEncapsulation,
} from '@angular/core';
import {FocusableOption} from '../core/a11y/focus-key-manager';
import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled';
import {Subject} from 'rxjs/Subject';
Expand Down Expand Up @@ -36,6 +42,7 @@ export const _MdMenuItemMixinBase = mixinDisabled(MdMenuItemBase);
'(mouseenter)': '_emitHoverEvent()',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
templateUrl: 'menu-item.html',
exportAs: 'mdMenuItem',
})
Expand Down
13 changes: 7 additions & 6 deletions src/lib/progress-bar/progress-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $mat-progress-bar-full-animation-duration: 2000ms !default;
$mat-progress-bar-piece-animation-duration: 250ms !default;


:host {
.mat-progress-bar {
display: block;
// Height is provided for md-progress-bar to act as a default.
height: $mat-progress-bar-height;
Expand Down Expand Up @@ -59,6 +59,12 @@ $mat-progress-bar-piece-animation-duration: 250ms !default;
left: 0;
}

// Reverse the apparent directionality of progress vars for rtl.
&[dir='rtl'],
[dir='rtl'] & {
transform: rotateY(180deg);
}

&[mode='query'] {
transform: rotateZ(180deg);
}
Expand Down Expand Up @@ -99,11 +105,6 @@ $mat-progress-bar-piece-animation-duration: 250ms !default;
}


// Reverse the apparent directionality of progress vars for rtl.
:host-context([dir='rtl']) {
transform: rotateY(180deg);
}

// The values used for animations in md-progress-bar, both timing and transformation, can be
// considered magic values. They are sourced from the Material Design example spec and duplicate
// the values of the original designers definitions.
Expand Down
3 changes: 2 additions & 1 deletion src/lib/progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Component, ChangeDetectionStrategy, Input} from '@angular/core';
import {Component, ChangeDetectionStrategy, Input, ViewEncapsulation} from '@angular/core';

// TODO(josephperrott): Benchpress tests.
// TODO(josephperrott): Add ARIA attributes for progressbar "for".
Expand All @@ -32,6 +32,7 @@ import {Component, ChangeDetectionStrategy, Input} from '@angular/core';
templateUrl: 'progress-bar.html',
styleUrls: ['progress-bar.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdProgressBar {
/** Color of the progress bar. */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/progress-spinner/progress-spinner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $mat-progress-spinner-stroke-width: 10px !default;
$mat-progress-spinner-viewport-size: 100px !default;


:host {
.mat-progress-spinner {
display: block;
// Height and width are provided for mat-progress-spinner to act as a default.
// The height and width are expected to be overwritten by application css.
Expand Down
6 changes: 5 additions & 1 deletion src/lib/progress-spinner/progress-spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Renderer2,
Directive,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {CanColor, mixinColor} from '../core/common-behaviors/color';

Expand Down Expand Up @@ -70,6 +71,7 @@ export const _MdProgressSpinnerMixinBase = mixinColor(MdProgressSpinnerBase, 'pr
selector: 'md-progress-spinner, mat-progress-spinner',
host: {
'role': 'progressbar',
'class': 'mat-progress-spinner',
'[attr.aria-valuemin]': '_ariaValueMin',
'[attr.aria-valuemax]': '_ariaValueMax',
'[attr.aria-valuenow]': 'value',
Expand All @@ -79,6 +81,7 @@ export const _MdProgressSpinnerMixinBase = mixinColor(MdProgressSpinnerBase, 'pr
templateUrl: 'progress-spinner.html',
styleUrls: ['progress-spinner.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdProgressSpinner extends _MdProgressSpinnerMixinBase
implements OnDestroy, CanColor {
Expand Down Expand Up @@ -279,12 +282,13 @@ export class MdProgressSpinner extends _MdProgressSpinnerMixinBase
host: {
'role': 'progressbar',
'mode': 'indeterminate',
'class': 'mat-spinner',
'class': 'mat-spinner mat-progress-spinner',
},
inputs: ['color'],
templateUrl: 'progress-spinner.html',
styleUrls: ['progress-spinner.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdSpinner extends MdProgressSpinner {
constructor(elementRef: ElementRef, ngZone: NgZone, renderer: Renderer2) {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectionStrategy, Component, Directive} from '@angular/core';
import {ChangeDetectionStrategy, Component, Directive, ViewEncapsulation} from '@angular/core';
import {
CdkHeaderRow,
CdkRow,
Expand Down Expand Up @@ -52,6 +52,7 @@ export class MdRowDef extends _MdCdkRowDef { }
'role': 'row',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdHeaderRow extends _MdHeaderRow { }

Expand All @@ -64,5 +65,6 @@ export class MdHeaderRow extends _MdHeaderRow { }
'role': 'row',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class MdRow extends _MdRow { }
8 changes: 4 additions & 4 deletions src/lib/tabs/tab-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import '../core/style/layout-common';
@import 'tabs-common';

:host {
.mat-tab-group {
display: flex;
flex-direction: column;

Expand All @@ -23,8 +23,8 @@
}
}

:host[md-stretch-tabs] .mat-tab-label,
:host[mat-stretch-tabs] .mat-tab-label {
.mat-tab-group[md-stretch-tabs] .mat-tab-label,
.mat-tab-group[mat-stretch-tabs] .mat-tab-label {
flex-basis: 0;
flex-grow: 1;
}
Expand All @@ -51,7 +51,7 @@
flex-grow: 1;
}

:host.mat-tab-group-dynamic-height &.mat-tab-body-active {
.mat-tab-group.mat-tab-group-dynamic-height &.mat-tab-body-active {
overflow-y: hidden;
}
}
2 changes: 2 additions & 0 deletions src/lib/tabs/tab-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
AfterContentInit,
AfterContentChecked,
OnDestroy,
ViewEncapsulation,
} from '@angular/core';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {map} from '@angular/cdk/rxjs';
Expand Down Expand Up @@ -62,6 +63,7 @@ export const _MdTabGroupMixinBase = mixinColor(mixinDisableRipple(MdTabGroupBase
selector: 'md-tab-group, mat-tab-group',
templateUrl: 'tab-group.html',
styleUrls: ['tab-group.css'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
inputs: ['color', 'disableRipple'],
host: {
Expand Down
15 changes: 13 additions & 2 deletions src/lib/tabs/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@

import {TemplatePortal} from '../core/portal/portal';
import {
ViewContainerRef, Input, TemplateRef, ViewChild, OnInit, ContentChild,
Component, ChangeDetectionStrategy, OnDestroy, OnChanges, SimpleChanges,
ChangeDetectionStrategy,
Component,
ContentChild,
Input,
OnChanges,
OnDestroy,
OnInit,
SimpleChanges,
TemplateRef,
ViewChild,
ViewContainerRef,
ViewEncapsulation,
} from '@angular/core';
import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled';
import {MdTabLabel} from './tab-label';
Expand All @@ -26,6 +36,7 @@ export const _MdTabMixinBase = mixinDisabled(MdTabBase);
templateUrl: 'tab.html',
inputs: ['disabled'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
exportAs: 'mdTab',
})
export class MdTab extends _MdTabMixinBase implements OnInit, CanDisable, OnChanges, OnDestroy {
Expand Down
48 changes: 48 additions & 0 deletions tools/tslint-rules/noViewEncapsulationRule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const Lint = require('tslint');
const ERROR_MESSAGE = 'Components must turn off view encapsulation.';

// TODO(crisbeto): combine this with the OnPush rule when it gets in.

/**
* Rule that enforces that view encapsulation is turned off on all components.
* Files can be whitelisted via `"no-view-encapsulation": [true, "\.spec\.ts$"]`.
*/
class Rule extends Lint.Rules.AbstractRule {
apply(file) {
return this.applyWithWalker(new Walker(file, this.getOptions()));
}
}

class Walker extends Lint.RuleWalker {
constructor(file, options) {
super(...arguments);

// Whitelist with regular expressions to use when determining which files to lint.
const whitelist = options.ruleArguments;

// Whether the file should be checked at all.
this._enabled = !whitelist.length || whitelist.some(p => new RegExp(p).test(file.fileName));
}

visitClassDeclaration(node) {
if (!this._enabled || !node.decorators) return;

node.decorators
.map(decorator => decorator.expression)
.filter(expression => expression.expression.getText() === 'Component')
.filter(expression => expression.arguments.length && expression.arguments[0].properties)
.forEach(expression => {
const hasTurnedOffEncapsulation = expression.arguments[0].properties.some(prop => {
const value = prop.initializer.getText();
return prop.name.getText() === 'encapsulation' && value.endsWith('.None');
});

if (!hasTurnedOffEncapsulation) {
this.addFailureAtNode(expression.parent, ERROR_MESSAGE);
}
});
}

}

exports.Rule = Rule;
4 changes: 4 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"check-type",
"check-preblock"
],
"no-view-encapsulation": [
true,
"(lib|cdk)\/((?!spec.ts).)*.ts$"
],
// Bans jasmine helper functions that will prevent the CI from properly running tests.
"ban": [
true,
Expand Down