This patch is a final major refactor in styling Angular. This PR includes three main fixes: All temporary state taht is persisted between template style/class application and style/class application in host bindings is now removed. Removes the styling() and stylingApply() instructions. Introduces a "direct apply" mode that is used apply prop-based style/class in the event that there are no map-based bindings as well as property collisions. PR Close #32259 PR Close #32596
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
import {NgForOfContext} from '@angular/common';
|
||||
|
||||
import {ɵɵdefineComponent} from '../../src/render3/definition';
|
||||
import {RenderFlags, ɵɵattribute, ɵɵclassMap, ɵɵelement, ɵɵelementEnd, ɵɵelementStart, ɵɵproperty, ɵɵselect, ɵɵstyleMap, ɵɵstyleProp, ɵɵstyleSanitizer, ɵɵstyling, ɵɵstylingApply, ɵɵtemplate, ɵɵtext, ɵɵtextInterpolate1} from '../../src/render3/index';
|
||||
import {RenderFlags, ɵɵattribute, ɵɵclassMap, ɵɵelement, ɵɵelementEnd, ɵɵelementStart, ɵɵproperty, ɵɵselect, ɵɵstyleMap, ɵɵstyleProp, ɵɵstyleSanitizer, ɵɵtemplate, ɵɵtext, ɵɵtextInterpolate1} from '../../src/render3/index';
|
||||
import {AttributeMarker} from '../../src/render3/interfaces/node';
|
||||
import {bypassSanitizationTrustHtml, bypassSanitizationTrustResourceUrl, bypassSanitizationTrustScript, bypassSanitizationTrustStyle, bypassSanitizationTrustUrl, getSanitizationBypassType, unwrapSafeValue} from '../../src/sanitization/bypass';
|
||||
import {ɵɵdefaultStyleSanitizer, ɵɵsanitizeHtml, ɵɵsanitizeResourceUrl, ɵɵsanitizeScript, ɵɵsanitizeStyle, ɵɵsanitizeUrl} from '../../src/sanitization/sanitization';
|
||||
@ -20,11 +20,7 @@ import {NgForOf} from './common_with_def';
|
||||
import {ComponentFixture, TemplateFixture} from './render_util';
|
||||
|
||||
describe('instructions', () => {
|
||||
function createAnchor() {
|
||||
ɵɵelementStart(0, 'a');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
function createAnchor() { ɵɵelement(0, 'a'); }
|
||||
|
||||
function createDiv(initialClasses?: string[] | null, initialStyles?: string[] | null) {
|
||||
const attrs: any[] = [];
|
||||
@ -34,9 +30,7 @@ describe('instructions', () => {
|
||||
if (initialStyles) {
|
||||
attrs.push(AttributeMarker.Styles, ...initialStyles);
|
||||
}
|
||||
ɵɵelementStart(0, 'div', attrs);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelement(0, 'div', attrs);
|
||||
}
|
||||
|
||||
function createScript() { ɵɵelement(0, 'script'); }
|
||||
@ -156,7 +150,6 @@ describe('instructions', () => {
|
||||
t.update(() => {
|
||||
ɵɵstyleSanitizer(ɵɵdefaultStyleSanitizer);
|
||||
ɵɵstyleProp('background-image', 'url("http://server")');
|
||||
ɵɵstylingApply();
|
||||
});
|
||||
// nothing is set because sanitizer suppresses it.
|
||||
expect(t.html).toEqual('<div></div>');
|
||||
@ -164,7 +157,6 @@ describe('instructions', () => {
|
||||
t.update(() => {
|
||||
ɵɵstyleSanitizer(ɵɵdefaultStyleSanitizer);
|
||||
ɵɵstyleProp('background-image', bypassSanitizationTrustStyle('url("http://server2")'));
|
||||
ɵɵstylingApply();
|
||||
});
|
||||
expect((t.hostElement.firstChild as HTMLElement).style.getPropertyValue('background-image'))
|
||||
.toEqual('url("http://server2")');
|
||||
@ -173,17 +165,12 @@ describe('instructions', () => {
|
||||
|
||||
describe('styleMap', () => {
|
||||
function createDivWithStyle() {
|
||||
ɵɵelementStart(0, 'div', [AttributeMarker.Styles, 'height', '10px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelement(0, 'div', [AttributeMarker.Styles, 'height', '10px']);
|
||||
}
|
||||
|
||||
it('should add style', () => {
|
||||
const fixture = new TemplateFixture(createDivWithStyle, () => {}, 1);
|
||||
fixture.update(() => {
|
||||
ɵɵstyleMap({'background-color': 'red'});
|
||||
ɵɵstylingApply();
|
||||
});
|
||||
fixture.update(() => { ɵɵstyleMap({'background-color': 'red'}); });
|
||||
expect(fixture.html).toEqual('<div style="background-color: red; height: 10px;"></div>');
|
||||
});
|
||||
|
||||
@ -205,7 +192,6 @@ describe('instructions', () => {
|
||||
'filter': 'filter',
|
||||
'width': 'width'
|
||||
});
|
||||
ɵɵstylingApply();
|
||||
});
|
||||
|
||||
const props = detectedValues.sort();
|
||||
@ -216,18 +202,11 @@ describe('instructions', () => {
|
||||
});
|
||||
|
||||
describe('elementClass', () => {
|
||||
function createDivWithStyling() {
|
||||
ɵɵelementStart(0, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
function createDivWithStyling() { ɵɵelement(0, 'div'); }
|
||||
|
||||
it('should add class', () => {
|
||||
const fixture = new TemplateFixture(createDivWithStyling, () => {}, 1);
|
||||
fixture.update(() => {
|
||||
ɵɵclassMap('multiple classes');
|
||||
ɵɵstylingApply();
|
||||
});
|
||||
fixture.update(() => { ɵɵclassMap('multiple classes'); });
|
||||
expect(fixture.html).toEqual('<div class="classes multiple"></div>');
|
||||
});
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {RendererType2} from '../../src/render/api';
|
||||
import {getLContext} from '../../src/render3/context_discovery';
|
||||
import {AttributeMarker, ɵɵadvance, ɵɵattribute, ɵɵdefineComponent, ɵɵdefineDirective, ɵɵhostProperty, ɵɵproperty} from '../../src/render3/index';
|
||||
import {ɵɵallocHostVars, ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵelement, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵprojection, ɵɵprojectionDef, ɵɵstyling, ɵɵstylingApply, ɵɵtemplate, ɵɵtext, ɵɵtextInterpolate} from '../../src/render3/instructions/all';
|
||||
import {ɵɵallocHostVars, ɵɵcontainer, ɵɵcontainerRefreshEnd, ɵɵcontainerRefreshStart, ɵɵelement, ɵɵelementEnd, ɵɵelementStart, ɵɵembeddedViewEnd, ɵɵembeddedViewStart, ɵɵprojection, ɵɵprojectionDef, ɵɵtemplate, ɵɵtext, ɵɵtextInterpolate} from '../../src/render3/instructions/all';
|
||||
import {MONKEY_PATCH_KEY_NAME} from '../../src/render3/interfaces/context';
|
||||
import {RenderFlags} from '../../src/render3/interfaces/definition';
|
||||
import {RElement, Renderer3, RendererFactory3, domRendererFactory3} from '../../src/render3/interfaces/renderer';
|
||||
@ -630,12 +630,7 @@ describe('element discovery', () => {
|
||||
vars: 0,
|
||||
template: (rf: RenderFlags, ctx: StructuredComp) => {
|
||||
if (rf & RenderFlags.Create) {
|
||||
ɵɵelementStart(0, 'section');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
if (rf & RenderFlags.Update) {
|
||||
ɵɵstylingApply();
|
||||
ɵɵelement(0, 'section');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -6,11 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {ɵɵadvance} from '../../../../src/render3/instructions/advance';
|
||||
import {ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {refreshView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TVIEW} from '../../../../src/render3/interfaces/view';
|
||||
import {ɵɵclassMap, ɵɵstyleMap, ɵɵstyling, ɵɵstylingApply} from '../../../../src/render3/styling_next/instructions';
|
||||
import {ɵɵclassMap, ɵɵstyleMap} from '../../../../src/render3/styling_next/instructions';
|
||||
import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
|
||||
`<ng-template>
|
||||
@ -30,79 +30,49 @@ import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
function testTemplate(rf: RenderFlags, ctx: any) {
|
||||
if (rf & 1) {
|
||||
ɵɵelementStart(0, 'div');
|
||||
ɵɵelementStart(1, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(2, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(3, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(4, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(5, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(6, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(7, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(8, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(9, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(10, 'div');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelement(1, 'div');
|
||||
ɵɵelement(2, 'div');
|
||||
ɵɵelement(3, 'div');
|
||||
ɵɵelement(4, 'div');
|
||||
ɵɵelement(5, 'div');
|
||||
ɵɵelement(6, 'div');
|
||||
ɵɵelement(7, 'div');
|
||||
ɵɵelement(8, 'div');
|
||||
ɵɵelement(9, 'div');
|
||||
ɵɵelement(10, 'div');
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
if (rf & 2) {
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '0px', height: '0px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '10px', height: '100px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '20px', height: '200px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '30px', height: '300px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '40px', height: '400px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '50px', height: '500px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '60px', height: '600px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '70px', height: '700px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '80px', height: '800px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleMap({width: '90px', height: '900px'});
|
||||
ɵɵclassMap('one two');
|
||||
ɵɵstylingApply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {ɵɵadvance} from '../../../../src/render3/instructions/advance';
|
||||
import {ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {refreshView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {AttributeMarker} from '../../../../src/render3/interfaces/node';
|
||||
import {TVIEW} from '../../../../src/render3/interfaces/view';
|
||||
import {ɵɵclassProp, ɵɵstyleProp, ɵɵstyling, ɵɵstylingApply} from '../../../../src/render3/styling_next/instructions';
|
||||
import {ɵɵclassProp, ɵɵstyleProp} from '../../../../src/render3/styling_next/instructions';
|
||||
import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
|
||||
`<ng-template>
|
||||
@ -31,89 +31,50 @@ import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
function testTemplate(rf: RenderFlags, ctx: any) {
|
||||
if (rf & 1) {
|
||||
ɵɵelementStart(0, 'div', [AttributeMarker.Classes, 'list']);
|
||||
ɵɵelementStart(
|
||||
1, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
2, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
3, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
4, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
5, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
6, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
7, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
8, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
9, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(
|
||||
ɵɵelement(1, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(2, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(3, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(4, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(5, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(6, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(7, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(8, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(9, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵelement(
|
||||
10, 'div', [AttributeMarker.Classes, 'item', AttributeMarker.Styles, 'width', '50px']);
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
if (rf & 2) {
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '0px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '100px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '200px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '300px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '400px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '500px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '600px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '700px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '800px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('width', '900px');
|
||||
ɵɵclassProp('scale', true);
|
||||
ɵɵstylingApply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {ɵɵadvance} from '../../../../src/render3/instructions/advance';
|
||||
import {ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {ɵɵelement, ɵɵelementEnd, ɵɵelementStart} from '../../../../src/render3/instructions/element';
|
||||
import {refreshView} from '../../../../src/render3/instructions/shared';
|
||||
import {RenderFlags} from '../../../../src/render3/interfaces/definition';
|
||||
import {TVIEW} from '../../../../src/render3/interfaces/view';
|
||||
import {ɵɵstyleProp, ɵɵstyling, ɵɵstylingApply} from '../../../../src/render3/styling_next/instructions';
|
||||
import {ɵɵstyleProp} from '../../../../src/render3/styling_next/instructions';
|
||||
import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
|
||||
`<ng-template>
|
||||
@ -30,69 +30,39 @@ import {setupRootViewWithEmbeddedViews} from '../setup';
|
||||
function testTemplate(rf: RenderFlags, ctx: any) {
|
||||
if (rf & 1) {
|
||||
ɵɵelementStart(0, 'div');
|
||||
ɵɵelementStart(1, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(2, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(3, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(4, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(5, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(6, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(7, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(8, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(9, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelementStart(10, 'button');
|
||||
ɵɵstyling();
|
||||
ɵɵelementEnd();
|
||||
ɵɵelement(1, 'button');
|
||||
ɵɵelement(2, 'button');
|
||||
ɵɵelement(3, 'button');
|
||||
ɵɵelement(4, 'button');
|
||||
ɵɵelement(5, 'button');
|
||||
ɵɵelement(6, 'button');
|
||||
ɵɵelement(7, 'button');
|
||||
ɵɵelement(8, 'button');
|
||||
ɵɵelement(9, 'button');
|
||||
ɵɵelement(10, 'button');
|
||||
ɵɵelementEnd();
|
||||
}
|
||||
if (rf & 2) {
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color1');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color2');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color3');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color4');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color5');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color6');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color7');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color8');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color9');
|
||||
ɵɵstylingApply();
|
||||
ɵɵadvance(1);
|
||||
ɵɵstyleProp('background-color', 'color10');
|
||||
ɵɵstylingApply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {normalizeIntoStylingMap as createMap} from '../../../src/render3/styling_next/map_based_bindings';
|
||||
import {normalizeIntoStylingMap as createMap} from '../../../src/render3/styling_next/util';
|
||||
|
||||
describe('map-based bindings', () => {
|
||||
describe('StylingMapArray construction', () => {
|
||||
|
@ -5,8 +5,10 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {DEFAULT_GUARD_MASK_VALUE, registerBinding} from '@angular/core/src/render3/styling_next/bindings';
|
||||
import {registerBinding} from '@angular/core/src/render3/styling_next/bindings';
|
||||
import {attachStylingDebugObject} from '@angular/core/src/render3/styling_next/styling_debug';
|
||||
import {DEFAULT_GUARD_MASK_VALUE} from '@angular/core/src/render3/styling_next/util';
|
||||
|
||||
import {allocTStylingContext} from '../../../src/render3/styling_next/util';
|
||||
|
||||
describe('styling context', () => {
|
||||
@ -15,33 +17,36 @@ describe('styling context', () => {
|
||||
const context = debug.context;
|
||||
expect(debug.entries).toEqual({});
|
||||
|
||||
registerBinding(context, 1, 'width', '100px');
|
||||
registerBinding(context, 1, 0, 'width', '100px');
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
valuesCount: 1,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(),
|
||||
templateBitMask: buildGuardMask(),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: '100px',
|
||||
sources: ['100px'],
|
||||
});
|
||||
|
||||
registerBinding(context, 2, 'width', 20);
|
||||
registerBinding(context, 2, 0, 'width', 20);
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
sanitizationRequired: false,
|
||||
valuesCount: 2,
|
||||
guardMask: buildGuardMask(2),
|
||||
templateBitMask: buildGuardMask(2),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: '100px',
|
||||
sources: [20, '100px'],
|
||||
});
|
||||
|
||||
registerBinding(context, 3, 'height', 10);
|
||||
registerBinding(context, 4, 'height', 15);
|
||||
registerBinding(context, 3, 0, 'height', 10);
|
||||
registerBinding(context, 4, 1, 'height', 15);
|
||||
expect(debug.entries['height']).toEqual({
|
||||
prop: 'height',
|
||||
valuesCount: 3,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(3, 4),
|
||||
templateBitMask: buildGuardMask(3),
|
||||
hostBindingsBitMask: buildGuardMask(4),
|
||||
defaultValue: null,
|
||||
sources: [10, 15, null],
|
||||
});
|
||||
@ -52,13 +57,14 @@ describe('styling context', () => {
|
||||
const context = debug.context;
|
||||
expect(debug.entries).toEqual({});
|
||||
|
||||
registerBinding(context, 1, 'width', 123);
|
||||
registerBinding(context, 1, 'width', 123);
|
||||
registerBinding(context, 1, 0, 'width', 123);
|
||||
registerBinding(context, 1, 0, 'width', 123);
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
valuesCount: 2,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(1),
|
||||
templateBitMask: buildGuardMask(1),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: null,
|
||||
sources: [123, null],
|
||||
});
|
||||
@ -68,33 +74,36 @@ describe('styling context', () => {
|
||||
const debug = makeContextWithDebug();
|
||||
const context = debug.context;
|
||||
|
||||
registerBinding(context, 1, 'width', null);
|
||||
registerBinding(context, 1, 0, 'width', null);
|
||||
const x = debug.entries['width'];
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
valuesCount: 1,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(),
|
||||
templateBitMask: buildGuardMask(),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: null,
|
||||
sources: [null]
|
||||
});
|
||||
|
||||
registerBinding(context, 1, 'width', '100px');
|
||||
registerBinding(context, 1, 0, 'width', '100px');
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
valuesCount: 1,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(),
|
||||
templateBitMask: buildGuardMask(),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: '100px',
|
||||
sources: ['100px']
|
||||
});
|
||||
|
||||
registerBinding(context, 1, 'width', '200px');
|
||||
registerBinding(context, 1, 0, 'width', '200px');
|
||||
expect(debug.entries['width']).toEqual({
|
||||
prop: 'width',
|
||||
valuesCount: 1,
|
||||
sanitizationRequired: false,
|
||||
guardMask: buildGuardMask(),
|
||||
templateBitMask: buildGuardMask(),
|
||||
hostBindingsBitMask: buildGuardMask(),
|
||||
defaultValue: '100px',
|
||||
sources: ['100px']
|
||||
});
|
||||
|
@ -18,7 +18,7 @@ describe('styling debugging tools', () => {
|
||||
const data: any[] = [];
|
||||
const d = new NodeStylingDebug(context, data);
|
||||
|
||||
registerBinding(context, 0, 'width', null);
|
||||
registerBinding(context, 0, 0, 'width', null);
|
||||
expect(d.summary).toEqual({
|
||||
width: {
|
||||
prop: 'width',
|
||||
@ -27,7 +27,7 @@ describe('styling debugging tools', () => {
|
||||
},
|
||||
});
|
||||
|
||||
registerBinding(context, 0, 'width', '100px');
|
||||
registerBinding(context, 0, 0, 'width', '100px');
|
||||
expect(d.summary).toEqual({
|
||||
width: {
|
||||
prop: 'width',
|
||||
@ -39,7 +39,7 @@ describe('styling debugging tools', () => {
|
||||
const someBindingIndex1 = 1;
|
||||
data[someBindingIndex1] = '200px';
|
||||
|
||||
registerBinding(context, 0, 'width', someBindingIndex1);
|
||||
registerBinding(context, 0, 0, 'width', someBindingIndex1);
|
||||
expect(d.summary).toEqual({
|
||||
width: {
|
||||
prop: 'width',
|
||||
@ -51,7 +51,7 @@ describe('styling debugging tools', () => {
|
||||
const someBindingIndex2 = 2;
|
||||
data[someBindingIndex2] = '500px';
|
||||
|
||||
registerBinding(context, 0, 'width', someBindingIndex2);
|
||||
registerBinding(context, 0, 1, 'width', someBindingIndex2);
|
||||
expect(d.summary).toEqual({
|
||||
width: {
|
||||
prop: 'width',
|
||||
|
Reference in New Issue
Block a user