refactor(ivy): don't include removed classes in the styling debug (#34375)
This is mostly done to allign behaviour with DebugElement.classes and remove Proxy usage (not supported in IE10/11). PR Close #34375
This commit is contained in:
parent
a9e3cbd534
commit
0fba79cda2
|
@ -5,7 +5,6 @@
|
||||||
* Use of this source code is governed by an MIT-style license that can be
|
* 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
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import {createProxy} from '../../debug/proxy';
|
|
||||||
import {StyleSanitizeFn} from '../../sanitization/style_sanitizer';
|
import {StyleSanitizeFn} from '../../sanitization/style_sanitizer';
|
||||||
import {TNodeFlags} from '../interfaces/node';
|
import {TNodeFlags} from '../interfaces/node';
|
||||||
import {RElement} from '../interfaces/renderer';
|
import {RElement} from '../interfaces/renderer';
|
||||||
|
@ -141,7 +140,7 @@ export interface DebugNodeStylingEntry {
|
||||||
prop: string;
|
prop: string;
|
||||||
|
|
||||||
/** The last applied value for the style/class property */
|
/** The last applied value for the style/class property */
|
||||||
value: string|boolean|null;
|
value: string|null;
|
||||||
|
|
||||||
/** The binding index of the last applied style/class property */
|
/** The binding index of the last applied style/class property */
|
||||||
bindingIndex: number|null;
|
bindingIndex: number|null;
|
||||||
|
@ -378,7 +377,6 @@ export class NodeStylingDebug implements DebugNodeStyling {
|
||||||
get summary(): {[key: string]: DebugNodeStylingEntry} {
|
get summary(): {[key: string]: DebugNodeStylingEntry} {
|
||||||
const entries: {[key: string]: DebugNodeStylingEntry} = {};
|
const entries: {[key: string]: DebugNodeStylingEntry} = {};
|
||||||
const config = this.config;
|
const config = this.config;
|
||||||
const isClassBased = this._isClassBased;
|
|
||||||
|
|
||||||
let data = this._data;
|
let data = this._data;
|
||||||
|
|
||||||
|
@ -396,33 +394,7 @@ export class NodeStylingDebug implements DebugNodeStyling {
|
||||||
entries[prop] = {prop, value, bindingIndex};
|
entries[prop] = {prop, value, bindingIndex};
|
||||||
});
|
});
|
||||||
|
|
||||||
// because the styling algorithm runs into two different
|
return entries;
|
||||||
// modes: direct and context-resolution, the output of the entries
|
|
||||||
// object is different because the removed values are not
|
|
||||||
// saved between updates. For this reason a proxy is created
|
|
||||||
// so that the behavior is the same when examining values
|
|
||||||
// that are no longer active on the element.
|
|
||||||
return createProxy({
|
|
||||||
get(target: {}, prop: string): DebugNodeStylingEntry{
|
|
||||||
let value: DebugNodeStylingEntry = entries[prop]; if (!value) {
|
|
||||||
value = {
|
|
||||||
prop,
|
|
||||||
value: isClassBased ? false : null,
|
|
||||||
bindingIndex: null,
|
|
||||||
};
|
|
||||||
} return value;
|
|
||||||
},
|
|
||||||
set(target: {}, prop: string, value: any) { return false; },
|
|
||||||
ownKeys() { return Object.keys(entries); },
|
|
||||||
getOwnPropertyDescriptor(k: any) {
|
|
||||||
// we use a special property descriptor here so that enumeration operations
|
|
||||||
// such as `Object.keys` will work on this proxy.
|
|
||||||
return {
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get config() { return buildConfig(this._tNode, this._isClassBased); }
|
get config() { return buildConfig(this._tNode, this._isClassBased); }
|
||||||
|
|
|
@ -1212,8 +1212,7 @@ describe('styling', () => {
|
||||||
|
|
||||||
classesSummary = classes.summary;
|
classesSummary = classes.summary;
|
||||||
abcSummary = classesSummary['abc'];
|
abcSummary = classesSummary['abc'];
|
||||||
expect(abcSummary.prop).toEqual('abc');
|
expect(abcSummary).toBeUndefined();
|
||||||
expect(abcSummary.value).toBeFalsy();
|
|
||||||
|
|
||||||
let defSummary = classesSummary['def'];
|
let defSummary = classesSummary['def'];
|
||||||
expect(defSummary.prop).toEqual('def');
|
expect(defSummary.prop).toEqual('def');
|
||||||
|
|
Loading…
Reference in New Issue