-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ngStyle, ngClass): StyleDirective security fixes & merge activate…
…d styles (#198) BREAKING CHANGE: * `[style.<alias>]` selectors are deprecated in favor of `[ngStyle.<alias>]` selectors * `[class.<alias>]` selectors are deprecated in favor of `[ngClass.<alias>]` selectors * default styles are merged with activated styles ```html <div fxLayout [class.xs]="['xs-1', 'xs-2']" [style]="{'font-size': '10px', 'margin-left' : '13px'}" [style.xs]="{'font-size': '16px'}" [style.md]="{'font-size': '12px'}"> </div> ``` ```html <div fxLayout [ngClass.xs]="['xs-1', 'xs-2']" [ngStyle]="{'font-size': '10px', 'margin-left' : '13px'}" [ngStyle.xs]="{'font-size': '16px'}" [ngStyle.md]="{'font-size': '12px'}"> </div> ``` Fixes #197.
- Loading branch information
1 parent
10e1230
commit eb22fe5
Showing
11 changed files
with
542 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {Component, OnDestroy} from '@angular/core'; | ||
import {Subscription} from "rxjs/Subscription"; | ||
import 'rxjs/add/operator/filter'; | ||
|
||
import {MediaChange} from "../../../lib/media-query/media-change"; | ||
import {ObservableMedia} from "../../../lib/media-query/observable-media-service"; | ||
|
||
// [ngStyle="{'font-size.px': 10, color: 'rgb(0,0,0)', 'text-align':'left'}" | ||
// style="font-size:10px; color:black; text-align:left;" | ||
@Component({ | ||
selector: 'demo-issue-197', | ||
styleUrls: [ | ||
'../demo-app/material2.css' | ||
], | ||
template: ` | ||
<md-card class="card-demo" > | ||
<md-card-title><a href="https://github.com/angular/flex-layout/issues/197" target="_blank">Issue #197</a></md-card-title> | ||
<md-card-subtitle>Responsive Style directive should merge with default inline style:</md-card-subtitle> | ||
<md-card-content> | ||
<div class="containerX"> | ||
<div class="coloredContainerX box fixed"> | ||
<div class="box1" | ||
fxFlexFill | ||
style="font-size:12px; color:black; text-align:left;" | ||
[style.sm]="{'font-size': '16px', color: '#a63db8', 'text-align': 'center'}" | ||
ngStyle.md="font-size: 24px; color : #0000ff; text-align: right;"> | ||
<div fxFlexFill <br/> | ||
style="font-size:10px; color:black; text-align:'left';"<br/> | ||
[style.sm]="{'font-size':'16px', color:#a63db8, text-align:'center' }"<br/> | ||
ngStyle.md="font-size:24px; color:#00f;" text-align:'right'><br/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</md-card-content> | ||
<md-card-footer style="width:95%;padding-left:20px;margin-top:-5px;"> | ||
<div class="hint" >Active mediaQuery: <span style="padding-left: 20px; color: rgba(0, 0, 0, 0.54)">{{ activeMediaQuery }}</span></div> | ||
</md-card-footer> | ||
</md-card> | ||
` | ||
}) | ||
export class DemoIssue197 implements OnDestroy { | ||
public activeMediaQuery = ""; | ||
|
||
constructor(media$: ObservableMedia) { | ||
this._watcher = media$.subscribe((change: MediaChange) => { | ||
let value = change ? `'${change.mqAlias}' = (${change.mediaQuery})` : ""; | ||
this.activeMediaQuery = value; | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._watcher.unsubscribe(); | ||
} | ||
|
||
private _watcher: Subscription; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.