refactor(ivy): always use styling helper methods when comparing values (#26149)

PR Close #26149
This commit is contained in:
Matias Niemelä 2018-09-28 13:01:29 -07:00 committed by Alex Rickabaugh
parent 32e479ffec
commit ab379ab72a
3 changed files with 12 additions and 10 deletions

View File

@ -7,12 +7,13 @@
*/
import {StyleSanitizeFn} from '../../sanitization/style_sanitizer';
import {InitialStylingFlags} from '../interfaces/definition';
import {LElementNode} from '../interfaces/node';
import {Renderer3, RendererStyleFlags3, isProceduralRenderer} from '../interfaces/renderer';
import {InitialStyles, StylingContext, StylingFlags, StylingIndex} from '../interfaces/styling';
import {createEmptyStylingContext, EMPTY_ARR, EMPTY_OBJ} from './util';
import {EMPTY_ARR, EMPTY_OBJ, createEmptyStylingContext} from './util';
/**
* Used clone a copy of a pre-computed template of a styling context.
@ -240,7 +241,7 @@ export function updateStylingMap(
// there is no point in setting this to dirty if the previously
// rendered value was being referenced by the initial style (or null)
if (initialValue !== newValue) {
if (hasValueChanged(flag, initialValue, newValue)) {
setDirty(context, ctxIndex, true);
dirty = true;
}
@ -252,10 +253,10 @@ export function updateStylingMap(
const valueToCompare = getValue(context, indexOfEntry);
const flagToCompare = getPointers(context, indexOfEntry);
swapMultiContextEntries(context, ctxIndex, indexOfEntry);
if (valueToCompare !== newValue) {
if (hasValueChanged(flagToCompare, valueToCompare, newValue)) {
const initialValue = getInitialValue(context, flagToCompare);
setValue(context, ctxIndex, newValue);
if (initialValue !== newValue) {
if (hasValueChanged(flagToCompare, initialValue, newValue)) {
setDirty(context, ctxIndex, true);
dirty = true;
}
@ -346,7 +347,7 @@ export function updateStyleProp(
// if the value is the same in the multi-area then there's no point in re-assembling
const valueForMulti = getValue(context, indexForMulti);
if (!valueForMulti || valueForMulti !== value) {
if (!valueForMulti || hasValueChanged(currFlag, valueForMulti, value)) {
let multiDirty = false;
let singleDirty = true;

View File

@ -5,8 +5,9 @@
* 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 {CorePlayerHandler} from '../../../src/render3/styling/core_player_handler';
import {PlayState} from '../../../src/render3/interfaces/player';
import {CorePlayerHandler} from '../../../src/render3/styling/core_player_handler';
import {MockPlayer} from './mock_player';
describe('CorePlayerHandler', () => {

View File

@ -7,13 +7,13 @@
*/
import {RenderFlags} from '@angular/core/src/render3';
import {addPlayer, getPlayers} from '../../../src/render3/player';
import {getOrCreatePlayerContext} from '../../../src/render3/styling/util';
import {QUERY_READ_FROM_NODE, defineComponent, getHostElement} from '../../../src/render3/index';
import {element, elementEnd, elementStart, elementStyling, elementStylingApply, load, markDirty} from '../../../src/render3/instructions';
import {PlayerContext, PlayState, Player, PlayerHandler} from '../../../src/render3/interfaces/player';
import {PlayState, Player, PlayerContext, PlayerHandler} from '../../../src/render3/interfaces/player';
import {RElement} from '../../../src/render3/interfaces/renderer';
import {addPlayer, getPlayers} from '../../../src/render3/player';
import {QueryList, query, queryRefresh} from '../../../src/render3/query';
import {getOrCreatePlayerContext} from '../../../src/render3/styling/util';
import {ComponentFixture} from '../render_util';
import {MockPlayer} from './mock_player';