mirror of https://gitee.com/antv-l7/antv-l7
feat: 修复 l7utils mini-adapter mixin 循环引用
This commit is contained in:
parent
f3390fab7c
commit
f0efd3868f
|
@ -84,6 +84,7 @@ export const $window = isMini ? miniWindow : globalWindow;
|
|||
export const $XMLHttpRequest = isMini ? XMLHttpRequest: globalWindow.XMLHttpRequest;
|
||||
export const $location = isMini ? location : globalWindow.location;
|
||||
|
||||
export { registerCanvas, registerCanvas2D } from './register';
|
||||
// TODO:
|
||||
// export { registerCanvas, registerCanvas2D } from './register';
|
||||
|
||||
export * from './EventIniter/index';
|
||||
|
|
|
@ -1,60 +1,64 @@
|
|||
// @ts-nocheck
|
||||
// tslint:disable
|
||||
import { screen } from '../screen';
|
||||
|
||||
const { availWidth: innerWidth, availHeight: innerHeight } = screen;
|
||||
import { document } from '../document';
|
||||
const documentElement = {
|
||||
style: [],
|
||||
};
|
||||
|
||||
export function parentNode(obj, level?: number) {
|
||||
export function parentNode(obj: any, level?: number) {
|
||||
if (!('parentNode' in obj)) {
|
||||
let _parent;
|
||||
let parent;
|
||||
|
||||
if (level === 0) {
|
||||
_parent = function() {
|
||||
parent = () => {
|
||||
// return document
|
||||
return null;
|
||||
};
|
||||
} else if (level === 1) {
|
||||
_parent = function() {
|
||||
return document.documentElement;
|
||||
parent = () => {
|
||||
// return document.documentElement;
|
||||
return documentElement;
|
||||
};
|
||||
} else {
|
||||
_parent = function() {
|
||||
return document.body;
|
||||
parent = () => {
|
||||
// return document.body;
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, 'parentNode', {
|
||||
enumerable: true,
|
||||
get: _parent,
|
||||
get: parent,
|
||||
});
|
||||
}
|
||||
|
||||
if (!('parentElement' in obj)) {
|
||||
let _parent;
|
||||
let parent;
|
||||
|
||||
if (level === 0) {
|
||||
_parent = function() {
|
||||
parent = () => {
|
||||
return null;
|
||||
};
|
||||
} else if (level === 1) {
|
||||
_parent = function() {
|
||||
return document.documentElement;
|
||||
parent = () => {
|
||||
// return document.documentElement;
|
||||
return documentElement;
|
||||
};
|
||||
} else {
|
||||
_parent = function() {
|
||||
return document.body;
|
||||
parent = () => {
|
||||
// return document.body;
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, 'parentElement', {
|
||||
enumerable: true,
|
||||
get: _parent,
|
||||
get: parent,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function style(obj) {
|
||||
export function style(obj: any) {
|
||||
obj.style = obj.style || {};
|
||||
|
||||
Object.assign(obj.style, {
|
||||
|
@ -67,7 +71,7 @@ export function style(obj) {
|
|||
});
|
||||
}
|
||||
|
||||
export function clientRegion(obj) {
|
||||
export function clientRegion(obj: any) {
|
||||
if (!('clientLeft' in obj)) {
|
||||
obj.clientLeft = 0;
|
||||
obj.clientTop = 0;
|
||||
|
@ -95,7 +99,7 @@ export function clientRegion(obj) {
|
|||
}
|
||||
}
|
||||
|
||||
export function offsetRegion(obj) {
|
||||
export function offsetRegion(obj: any) {
|
||||
if (!('offsetLeft' in obj)) {
|
||||
obj.offsetLeft = 0;
|
||||
obj.offsetTop = 0;
|
||||
|
@ -106,7 +110,7 @@ export function offsetRegion(obj) {
|
|||
}
|
||||
}
|
||||
|
||||
export function scrollRegion(obj) {
|
||||
export function scrollRegion(obj: any) {
|
||||
if (!('scrollLeft' in obj)) {
|
||||
obj.scrollLeft = 0;
|
||||
obj.scrollTop = 0;
|
||||
|
@ -117,8 +121,8 @@ export function scrollRegion(obj) {
|
|||
}
|
||||
}
|
||||
|
||||
export function classList(obj) {
|
||||
const noop = function() {};
|
||||
export function classList(obj: any) {
|
||||
const noop = () => true;
|
||||
obj.classList = [];
|
||||
obj.classList.add = noop;
|
||||
obj.classList.remove = noop;
|
||||
|
|
Loading…
Reference in New Issue