@micro-zoe/micro-app 1.0.0-rc.11 → 1.0.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +25 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -158,6 +158,7 @@ declare module '@micro-zoe/micro-app/libs/utils' {
|
|
|
158
158
|
export function isDocumentShadowRoot(target: unknown): target is DocumentFragment;
|
|
159
159
|
export function isMicroAppBody(target: unknown): target is HTMLElement;
|
|
160
160
|
export function isMicroAppHead(target: unknown): target is HTMLElement;
|
|
161
|
+
export function isWebComponentElement(target: unknown): boolean;
|
|
161
162
|
export function isProxyDocument(target: unknown): target is Document;
|
|
162
163
|
export function isTargetExtension(path: string, suffix: string): boolean;
|
|
163
164
|
export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
|
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-rc.
|
|
1
|
+
const version = '1.0.0-rc.13';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -131,6 +131,14 @@ function isMicroAppBody(target) {
|
|
|
131
131
|
function isMicroAppHead(target) {
|
|
132
132
|
return isElement(target) && target.tagName.toUpperCase() === 'MICRO-APP-HEAD';
|
|
133
133
|
}
|
|
134
|
+
function isWebComponentElement(target) {
|
|
135
|
+
let result = toTypeString(target) === '[object HTMLElement]';
|
|
136
|
+
if (result) {
|
|
137
|
+
const tagName = target.tagName.toUpperCase();
|
|
138
|
+
result = result && !tagName.startsWith('MICRO-APP');
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
134
142
|
// is ProxyDocument
|
|
135
143
|
function isProxyDocument(target) {
|
|
136
144
|
return toTypeString(target) === '[object ProxyDocument]';
|
|
@@ -3002,15 +3010,14 @@ function updateElementInfo(node, appName) {
|
|
|
3002
3010
|
return this.getAttribute('href');
|
|
3003
3011
|
},
|
|
3004
3012
|
set(value) {
|
|
3013
|
+
if (value === undefined) {
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3005
3016
|
this.setAttribute('href', value);
|
|
3006
3017
|
},
|
|
3007
3018
|
};
|
|
3008
3019
|
}
|
|
3009
3020
|
}
|
|
3010
|
-
if (isImageElement(node) || isVideoElement(node) || isAudioElement(node)) {
|
|
3011
|
-
// @ts-ignore
|
|
3012
|
-
node.crossOrigin = 'anonymous';
|
|
3013
|
-
}
|
|
3014
3021
|
rawDefineProperties(node, props);
|
|
3015
3022
|
/**
|
|
3016
3023
|
* In FireFox, iframe Node.prototype will point to native Node.prototype after insert to document
|
|
@@ -5482,8 +5489,10 @@ function patchRouter(appName, url, microAppWindow, browserHost) {
|
|
|
5482
5489
|
return createMicroLocation(appName, url, microAppWindow, childStaticLocation, browserHost, childHost);
|
|
5483
5490
|
}
|
|
5484
5491
|
|
|
5492
|
+
const UN_PROXY_INSTANCEOF_KEYS = [
|
|
5493
|
+
'Array'
|
|
5494
|
+
];
|
|
5485
5495
|
const escape2RawWindowKeys = [
|
|
5486
|
-
'Array',
|
|
5487
5496
|
'getComputedStyle',
|
|
5488
5497
|
// FIX ISSUE: https://github.com/micro-zoe/micro-app/issues/1292
|
|
5489
5498
|
'DOMParser',
|
|
@@ -5688,7 +5697,7 @@ function patchWindowProperty$1(appName, microAppWindow, sandbox) {
|
|
|
5688
5697
|
* 4. native url instanceof iframe window.URL
|
|
5689
5698
|
* ...
|
|
5690
5699
|
*/
|
|
5691
|
-
if (isConstructor(microAppWindow[key]) && key in rawWindow) {
|
|
5700
|
+
if (isConstructor(microAppWindow[key]) && key in rawWindow && !UN_PROXY_INSTANCEOF_KEYS.includes(key)) {
|
|
5692
5701
|
rawDefineProperty(microAppWindow[key], Symbol.hasInstance, {
|
|
5693
5702
|
configurable: true,
|
|
5694
5703
|
enumerable: false,
|
|
@@ -5927,7 +5936,10 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
5927
5936
|
return range;
|
|
5928
5937
|
};
|
|
5929
5938
|
microRootDocument.prototype.createElement = function createElement(tagName, options) {
|
|
5930
|
-
|
|
5939
|
+
let element = rawMicroCreateElement.call(this, tagName, options);
|
|
5940
|
+
if (isWebComponentElement(element)) {
|
|
5941
|
+
element = rawMicroCreateElement.call(rawDocument, tagName, options);
|
|
5942
|
+
}
|
|
5931
5943
|
return updateElementInfo(element, appName);
|
|
5932
5944
|
};
|
|
5933
5945
|
microRootDocument.prototype.createElementNS = function createElementNS(namespaceURI, name, options) {
|
|
@@ -6448,7 +6460,11 @@ function patchIframeAttribute(url, microAppWindow) {
|
|
|
6448
6460
|
else {
|
|
6449
6461
|
if (((key === 'src' || key === 'srcset') && /^(img|script|video|audio|source|embed)$/i.test(this.tagName)) ||
|
|
6450
6462
|
(key === 'href' && /^(a|link|image)$/i.test(this.tagName))) {
|
|
6451
|
-
|
|
6463
|
+
let _url = url;
|
|
6464
|
+
if (isBrowser && key === 'href' && /^a$/i.test(this.tagName) && isFunction(microApp.options.excludeAssetFilter) && microApp.options.excludeAssetFilter(value)) {
|
|
6465
|
+
_url = document.baseURI;
|
|
6466
|
+
}
|
|
6467
|
+
value = CompletionPath(value, _url);
|
|
6452
6468
|
}
|
|
6453
6469
|
rawMicroSetAttribute.call(this, key, value);
|
|
6454
6470
|
}
|