refactor(ivy): remove usage of Proxy for IE10/11 compatibility (#34328)
PR Close #34328
This commit is contained in:

committed by
Kara Erickson

parent
b405942b0c
commit
a781800276
@ -18,9 +18,6 @@ import {getComponentLViewByIndex, getNativeByTNodeOrNull} from '../render3/util/
|
||||
import {assertDomNode} from '../util/assert';
|
||||
import {DebugContext} from '../view/index';
|
||||
|
||||
import {createProxy} from './proxy';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @publicApi
|
||||
@ -204,6 +201,7 @@ function _queryNodeChildren(
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class DebugNode__POST_R3__ implements DebugNode {
|
||||
readonly nativeNode: Node;
|
||||
|
||||
@ -348,35 +346,14 @@ class DebugElement__POST_R3__ extends DebugNode__POST_R3__ implements DebugEleme
|
||||
return {};
|
||||
}
|
||||
|
||||
private _classesProxy !: {};
|
||||
get classes(): {[key: string]: boolean;} {
|
||||
if (!this._classesProxy) {
|
||||
const element = this.nativeElement;
|
||||
const result: {[key: string]: boolean;} = {};
|
||||
const element = this.nativeElement as HTMLElement;
|
||||
const classNames = element.className.split(' ');
|
||||
|
||||
// we use a proxy here because VE code expects `.classes` to keep
|
||||
// track of which classes have been added and removed. Because we
|
||||
// do not make use of a debug renderer anymore, the return value
|
||||
// must always be `false` in the event that a class does not exist
|
||||
// on the element (even if it wasn't added and removed beforehand).
|
||||
this._classesProxy = createProxy({
|
||||
get(target: {}, prop: string) {
|
||||
return element ? element.classList.contains(prop) : false;
|
||||
},
|
||||
set(target: {}, prop: string, value: any) {
|
||||
return element ? element.classList.toggle(prop, !!value) : false;
|
||||
},
|
||||
ownKeys() { return element ? Array.from(element.classList).sort() : []; },
|
||||
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,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
return this._classesProxy;
|
||||
classNames.forEach((value: string) => result[value] = true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
get childNodes(): DebugNode[] {
|
||||
|
Reference in New Issue
Block a user