refactor: remove toplevel property accesses (#29329)

PR Close #29329
This commit is contained in:
Filipe Silva
2019-05-02 16:44:24 +01:00
committed by Jason Aden
parent 739e5a4f53
commit ac34a1429b
32 changed files with 231 additions and 253 deletions

View File

@ -34,9 +34,10 @@ export class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
}
}
const DIMENSIONAL_PROP_MAP = makeBooleanMap(
'width,height,minWidth,minHeight,maxWidth,maxHeight,left,top,bottom,right,fontSize,outlineWidth,outlineOffset,paddingTop,paddingLeft,paddingBottom,paddingRight,marginTop,marginLeft,marginBottom,marginRight,borderRadius,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,textIndent,perspective'
.split(','));
const DIMENSIONAL_PROP_MAP =
(() => makeBooleanMap(
'width,height,minWidth,minHeight,maxWidth,maxHeight,left,top,bottom,right,fontSize,outlineWidth,outlineOffset,paddingTop,paddingLeft,paddingBottom,paddingRight,marginTop,marginLeft,marginBottom,marginRight,borderRadius,borderWidth,borderTopWidth,borderLeftWidth,borderRightWidth,borderBottomWidth,textIndent,perspective'
.split(',')))();
function makeBooleanMap(keys: string[]): {[key: string]: boolean} {
const map: {[key: string]: boolean} = {};

View File

@ -158,16 +158,20 @@ if (_isNode || typeof Element !== 'undefined') {
// this is well supported in all browsers
_contains = (elm1: any, elm2: any) => { return elm1.contains(elm2) as boolean; };
if (_isNode || Element.prototype.matches) {
_matches = (element: any, selector: string) => element.matches(selector);
} else {
const proto = Element.prototype as any;
const fn = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector ||
proto.oMatchesSelector || proto.webkitMatchesSelector;
if (fn) {
_matches = (element: any, selector: string) => fn.apply(element, [selector]);
_matches = (() => {
if (_isNode || Element.prototype.matches) {
return (element: any, selector: string) => element.matches(selector);
} else {
const proto = Element.prototype as any;
const fn = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector ||
proto.oMatchesSelector || proto.webkitMatchesSelector;
if (fn) {
return (element: any, selector: string) => fn.apply(element, [selector]);
} else {
return _matches;
}
}
}
})();
_query = (element: any, selector: string, multi: boolean): any[] => {
let results: any[] = [];