@micro-zoe/micro-app 1.0.0-rc.25 → 1.0.0-rc.26

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.25';
1
+ const version = '1.0.0-rc.26';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
@@ -3118,7 +3118,7 @@ function getIframeParentNodeDesc(appName, parentNodeDesc) {
3118
3118
  configurable: true,
3119
3119
  enumerable: true,
3120
3120
  get() {
3121
- var _a, _b, _c, _d;
3121
+ var _a, _b, _c, _d, _e, _f, _g;
3122
3122
  throttleDeferForIframeAppName(appName);
3123
3123
  const result = (_a = parentNodeDesc.get) === null || _a === void 0 ? void 0 : _a.call(this);
3124
3124
  /**
@@ -3133,7 +3133,14 @@ function getIframeParentNodeDesc(appName, parentNodeDesc) {
3133
3133
  * e.g. target.parentNode.remove(target)
3134
3134
  */
3135
3135
  if (isMicroAppBody(result) && ((_b = appInstanceMap.get(appName)) === null || _b === void 0 ? void 0 : _b.container)) {
3136
- return ((_d = (_c = microApp.options).getRootElementParentNode) === null || _d === void 0 ? void 0 : _d.call(_c, this, appName)) || globalEnv.rawDocument.body;
3136
+ const customParent = (_d = (_c = microApp.options).getRootElementParentNode) === null || _d === void 0 ? void 0 : _d.call(_c, this, appName);
3137
+ if (customParent) {
3138
+ return customParent;
3139
+ }
3140
+ if (((_e = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _e === void 0 ? void 0 : _e.inheritBaseBody) !== true) {
3141
+ return ((_g = (_f = appInstanceMap.get(appName)) === null || _f === void 0 ? void 0 : _f.container) === null || _g === void 0 ? void 0 : _g.querySelector('micro-app-body')) || globalEnv.rawDocument.body;
3142
+ }
3143
+ return globalEnv.rawDocument.body;
3137
3144
  }
3138
3145
  return result;
3139
3146
  }
@@ -5867,14 +5874,14 @@ function patchWindowEffect$1(microAppWindow) {
5867
5874
  const eventListenerMap = new Map();
5868
5875
  const sstEventListenerMap = new Map();
5869
5876
  function getEventTarget(type) {
5870
- var _a, _b;
5877
+ var _a;
5871
5878
  /**
5872
5879
  * TODO: SCOPE_WINDOW_EVENT_OF_IFRAME的事件非常少,有可能导致问题
5873
5880
  * 1、一些未知的需要绑定到iframe的事件被错误的绑定到原生window上
5874
5881
  */
5875
5882
  let escapeSandboxEvent = [];
5876
5883
  if (Array.isArray((_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.escapeIframeWindowEvents)) {
5877
- escapeSandboxEvent = (_b = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _b === void 0 ? void 0 : _b.escapeIframeWindowEvents;
5884
+ escapeSandboxEvent = microApp.options.escapeIframeWindowEvents;
5878
5885
  }
5879
5886
  const scopeWindowEvent = SCOPE_WINDOW_EVENT_OF_IFRAME.filter(item => !escapeSandboxEvent.includes(item));
5880
5887
  return scopeWindowEvent.includes(type) ? microAppWindow : rawWindow;
@@ -5968,6 +5975,13 @@ function patchDocument$1(appName, microAppWindow, sandbox) {
5968
5975
  patchDocumentProperty(appName, microAppWindow, sandbox);
5969
5976
  return patchDocumentEffect(appName, microAppWindow);
5970
5977
  }
5978
+ function getElementDocument(microDocument, rawDocument) {
5979
+ var _a;
5980
+ if ((_a = microApp === null || microApp === void 0 ? void 0 : microApp.options) === null || _a === void 0 ? void 0 : _a.disableIframeRootDocument) {
5981
+ return rawDocument;
5982
+ }
5983
+ return microDocument;
5984
+ }
5971
5985
  function patchDocumentPrototype(appName, microAppWindow) {
5972
5986
  const rawDocument = globalEnv.rawDocument;
5973
5987
  const microRootDocument = microAppWindow.Document;
@@ -5993,26 +6007,26 @@ function patchDocumentPrototype(appName, microAppWindow) {
5993
6007
  return range;
5994
6008
  };
5995
6009
  microRootDocument.prototype.createElement = function createElement(tagName, options) {
5996
- let element = rawMicroCreateElement.call(this, tagName, options);
6010
+ let element = rawMicroCreateElement.call(getElementDocument(this, rawDocument), tagName, options);
5997
6011
  if (isWebComponentElement(element)) {
5998
6012
  element = rawMicroCreateElement.call(rawDocument, tagName, options);
5999
6013
  }
6000
6014
  return updateElementInfo(element, appName);
6001
6015
  };
6002
6016
  microRootDocument.prototype.createElementNS = function createElementNS(namespaceURI, name, options) {
6003
- const element = rawMicroCreateElementNS.call(this, namespaceURI, name, options);
6017
+ const element = rawMicroCreateElementNS.call(getElementDocument(this, rawDocument), namespaceURI, name, options);
6004
6018
  return updateElementInfo(element, appName);
6005
6019
  };
6006
6020
  microRootDocument.prototype.createTextNode = function createTextNode(data) {
6007
- const element = rawMicroCreateTextNode.call(this, data);
6021
+ const element = rawMicroCreateTextNode.call(getElementDocument(this, rawDocument), data);
6008
6022
  return updateElementInfo(element, appName);
6009
6023
  };
6010
6024
  microRootDocument.prototype.createDocumentFragment = function createDocumentFragment() {
6011
- const element = rawMicroCreateDocumentFragment.call(this);
6025
+ const element = rawMicroCreateDocumentFragment.call(getElementDocument(this, rawDocument));
6012
6026
  return updateElementInfo(element, appName);
6013
6027
  };
6014
6028
  microRootDocument.prototype.createComment = function createComment(data) {
6015
- const element = rawMicroCreateComment.call(this, data);
6029
+ const element = rawMicroCreateComment.call(getElementDocument(this, rawDocument), data);
6016
6030
  return updateElementInfo(element, appName);
6017
6031
  };
6018
6032
  function getBindTarget(target) {
@@ -6071,7 +6085,7 @@ function patchDocumentPrototype(appName, microAppWindow) {
6071
6085
  return rawMicroGetElementById.call(_this, key);
6072
6086
  }
6073
6087
  try {
6074
- return querySelector.call(this, `#${key}`);
6088
+ return querySelector.call(getElementDocument(this, rawDocument), `#${key}`);
6075
6089
  }
6076
6090
  catch (_a) {
6077
6091
  return rawMicroGetElementById.call(_this, key);
@@ -6083,14 +6097,14 @@ function patchDocumentPrototype(appName, microAppWindow) {
6083
6097
  return rawMicroGetElementsByClassName.call(_this, key);
6084
6098
  }
6085
6099
  try {
6086
- return querySelectorAll.call(this, `.${key}`);
6100
+ return querySelectorAll.call(getElementDocument(this, rawDocument), `.${key}`);
6087
6101
  }
6088
6102
  catch (_a) {
6089
6103
  return rawMicroGetElementsByClassName.call(_this, key);
6090
6104
  }
6091
6105
  };
6092
6106
  microRootDocument.prototype.getElementsByTagName = function getElementsByTagName(key) {
6093
- const _this = getBindTarget(this);
6107
+ const _this = getBindTarget(getElementDocument(this, rawDocument));
6094
6108
  if (isUniqueElement(key) ||
6095
6109
  isInvalidQuerySelectorKey(key)) {
6096
6110
  return rawMicroGetElementsByTagName.call(_this, key);
@@ -6100,19 +6114,19 @@ function patchDocumentPrototype(appName, microAppWindow) {
6100
6114
  return rawMicroGetElementsByTagName.call(microDocument, key);
6101
6115
  }
6102
6116
  try {
6103
- return querySelectorAll.call(this, key);
6117
+ return querySelectorAll.call(getElementDocument(this, rawDocument), key);
6104
6118
  }
6105
6119
  catch (_a) {
6106
6120
  return rawMicroGetElementsByTagName.call(_this, key);
6107
6121
  }
6108
6122
  };
6109
6123
  microRootDocument.prototype.getElementsByName = function getElementsByName(key) {
6110
- const _this = getBindTarget(this);
6124
+ const _this = getBindTarget(getElementDocument(this, rawDocument));
6111
6125
  if (isInvalidQuerySelectorKey(key)) {
6112
6126
  return rawMicroGetElementsByName.call(_this, key);
6113
6127
  }
6114
6128
  try {
6115
- return querySelectorAll.call(this, `[name=${key}]`);
6129
+ return querySelectorAll.call(getElementDocument(this, rawDocument), `[name=${key}]`);
6116
6130
  }
6117
6131
  catch (_a) {
6118
6132
  return rawMicroGetElementsByName.call(_this, key);