@micro-zoe/micro-app 1.0.0-rc.12 → 1.0.0-rc.14

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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = '1.0.0-rc.12';
1
+ const version = '1.0.0-rc.14';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
@@ -3010,6 +3010,9 @@ function updateElementInfo(node, appName) {
3010
3010
  return this.getAttribute('href');
3011
3011
  },
3012
3012
  set(value) {
3013
+ if (value === undefined) {
3014
+ return;
3015
+ }
3013
3016
  this.setAttribute('href', value);
3014
3017
  },
3015
3018
  };
@@ -5486,8 +5489,10 @@ function patchRouter(appName, url, microAppWindow, browserHost) {
5486
5489
  return createMicroLocation(appName, url, microAppWindow, childStaticLocation, browserHost, childHost);
5487
5490
  }
5488
5491
 
5492
+ const UN_PROXY_INSTANCEOF_KEYS = [
5493
+ 'Array'
5494
+ ];
5489
5495
  const escape2RawWindowKeys = [
5490
- 'Array',
5491
5496
  'getComputedStyle',
5492
5497
  // FIX ISSUE: https://github.com/micro-zoe/micro-app/issues/1292
5493
5498
  'DOMParser',
@@ -5692,7 +5697,7 @@ function patchWindowProperty$1(appName, microAppWindow, sandbox) {
5692
5697
  * 4. native url instanceof iframe window.URL
5693
5698
  * ...
5694
5699
  */
5695
- if (isConstructor(microAppWindow[key]) && key in rawWindow) {
5700
+ if (isConstructor(microAppWindow[key]) && key in rawWindow && !UN_PROXY_INSTANCEOF_KEYS.includes(key)) {
5696
5701
  rawDefineProperty(microAppWindow[key], Symbol.hasInstance, {
5697
5702
  configurable: true,
5698
5703
  enumerable: false,
@@ -6454,8 +6459,14 @@ function patchIframeAttribute(url, microAppWindow) {
6454
6459
  }
6455
6460
  else {
6456
6461
  if (((key === 'src' || key === 'srcset') && /^(img|script|video|audio|source|embed)$/i.test(this.tagName)) ||
6457
- (key === 'href' && /^(a|link|image)$/i.test(this.tagName))) {
6458
- value = CompletionPath(value, url);
6462
+ (key === 'href' && /^(link|image)$/i.test(this.tagName)) ||
6463
+ // If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
6464
+ (key === 'href' && /^(a)$/i.test(this.tagName) && !/^#/.test(value))) {
6465
+ let _url = url;
6466
+ if (isBrowser && key === 'href' && /^a$/i.test(this.tagName) && isFunction(microApp.options.excludeAssetFilter) && microApp.options.excludeAssetFilter(value)) {
6467
+ _url = document.baseURI;
6468
+ }
6469
+ value = CompletionPath(value, _url);
6459
6470
  }
6460
6471
  rawMicroSetAttribute.call(this, key, value);
6461
6472
  }
@@ -7707,7 +7718,9 @@ function completePathDynamic(app, newChild) {
7707
7718
  globalEnv.rawSetAttribute.call(newChild, 'srcset', CompletionPath(newChild.getAttribute('srcset'), app.url));
7708
7719
  }
7709
7720
  }
7710
- else if (/^(a|link|image)$/i.test(newChild.tagName) && newChild.hasAttribute('href')) {
7721
+ else if ((/^(link|image)$/i.test(newChild.tagName) && newChild.hasAttribute('href')) ||
7722
+ // If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
7723
+ (/^(a)$/i.test(newChild.tagName) && newChild.hasAttribute('href') && !/^#/.test(newChild.getAttribute('href') || ''))) {
7711
7724
  globalEnv.rawSetAttribute.call(newChild, 'href', CompletionPath(newChild.getAttribute('href'), app.url));
7712
7725
  }
7713
7726
  }
@@ -7882,7 +7895,9 @@ function patchElementAndDocument() {
7882
7895
  if (appName &&
7883
7896
  appInstanceMap.has(appName) &&
7884
7897
  (((key === 'src' || key === 'srcset') && /^(img|script|video|audio|source|embed)$/i.test(this.tagName)) ||
7885
- (key === 'href' && /^(a|link|image)$/i.test(this.tagName)))) {
7898
+ (key === 'href' && /^(link|image)$/i.test(this.tagName)) ||
7899
+ // If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
7900
+ (key === 'href' && /^(a)$/i.test(this.tagName) && !/^#/.test(value)))) {
7886
7901
  const app = appInstanceMap.get(appName);
7887
7902
  value = CompletionPath(value, app.url);
7888
7903
  }