@micro-zoe/micro-app 1.0.0-rc.6 → 1.0.0-rc.7
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 +25 -12
- 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.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '1.0.0-rc.
|
|
1
|
+
const version = '1.0.0-rc.7';
|
|
2
2
|
// do not use isUndefined
|
|
3
3
|
const isBrowser = typeof window !== 'undefined';
|
|
4
4
|
// do not use isUndefined
|
|
@@ -4752,12 +4752,12 @@ function updateMicroLocation(appName, targetFullPath, microLocation, type) {
|
|
|
4752
4752
|
microLocation.self.href = targetHref;
|
|
4753
4753
|
}
|
|
4754
4754
|
/**
|
|
4755
|
-
* native
|
|
4756
|
-
*
|
|
4757
|
-
*
|
|
4758
|
-
*
|
|
4759
|
-
* 1
|
|
4760
|
-
* 2
|
|
4755
|
+
* The native mode also base of history.state, and the modification of the browser url cannot be controlled. It is very likely that the browser url and __MICRO_APP_STATE__ are different.
|
|
4756
|
+
* Especially during init of child or forward and backward of browser, because vue-router@4 will actively modify the browser URL, the above situation often occurs
|
|
4757
|
+
* To solve this problem, after child app is initialized and responds to the popstateEvent, it is determined whether __MICRO_APP_STATE__ and the browser url are different. If they are different, the browser url will updated to the address of __MICRO_APP_STATE__
|
|
4758
|
+
* NOTE:
|
|
4759
|
+
* 1. If __MICRO_APP_STATE__ is different from the URL, then the operation of updating the URL is correct, otherwise there will be a problem of inconsistency between the URL and the rendered page
|
|
4760
|
+
* 2. When there are multiple child app in native mode, if one of them changes the URL address, the other one will not change __MICRO_APP_STATE__, and refresh browser will cause problems
|
|
4761
4761
|
*/
|
|
4762
4762
|
const rawLocation = globalEnv.rawWindow.location;
|
|
4763
4763
|
if (isRouterModeCustom(appName) &&
|
|
@@ -5848,14 +5848,26 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
5848
5848
|
}
|
|
5849
5849
|
// query element👇
|
|
5850
5850
|
function querySelector(selectors) {
|
|
5851
|
-
var _a
|
|
5851
|
+
var _a;
|
|
5852
5852
|
const _this = getBindTarget(this);
|
|
5853
5853
|
if (!selectors ||
|
|
5854
5854
|
isUniqueElement(selectors) ||
|
|
5855
5855
|
rawDocument !== _this) {
|
|
5856
5856
|
return rawMicroQuerySelector.call(_this, selectors);
|
|
5857
5857
|
}
|
|
5858
|
-
|
|
5858
|
+
/**
|
|
5859
|
+
* The child app cannot query the base element inside iframe
|
|
5860
|
+
* Same for querySelectorAll
|
|
5861
|
+
*
|
|
5862
|
+
* Scenes:
|
|
5863
|
+
* 1. vue-router@4.x --> createWebHistory(base?: string)
|
|
5864
|
+
* const baseEl = document.querySelector('base')
|
|
5865
|
+
* base = (baseEl && baseEl.getAttribute('href')) || '/'
|
|
5866
|
+
*
|
|
5867
|
+
* Issue: https://github.com/micro-zoe/micro-app/issues/1335
|
|
5868
|
+
*/
|
|
5869
|
+
const result = (_a = appInstanceMap.get(appName)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
|
|
5870
|
+
return result || selectors === 'base' ? result : rawMicroQuerySelector.call(microDocument, selectors);
|
|
5859
5871
|
}
|
|
5860
5872
|
function querySelectorAll(selectors) {
|
|
5861
5873
|
var _a, _b;
|
|
@@ -5866,7 +5878,7 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
5866
5878
|
return rawMicroQuerySelectorAll.call(_this, selectors);
|
|
5867
5879
|
}
|
|
5868
5880
|
const result = (_b = (_a = appInstanceMap.get(appName)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selectors)) !== null && _b !== void 0 ? _b : [];
|
|
5869
|
-
return result.length ? result : rawMicroQuerySelectorAll.call(microDocument, selectors);
|
|
5881
|
+
return result.length || selectors === 'base' ? result : rawMicroQuerySelectorAll.call(microDocument, selectors);
|
|
5870
5882
|
}
|
|
5871
5883
|
microRootDocument.prototype.querySelector = querySelector;
|
|
5872
5884
|
microRootDocument.prototype.querySelectorAll = querySelectorAll;
|
|
@@ -5899,8 +5911,9 @@ function patchDocumentPrototype(appName, microAppWindow) {
|
|
|
5899
5911
|
if (isUniqueElement(key) ||
|
|
5900
5912
|
isInvalidQuerySelectorKey(key)) {
|
|
5901
5913
|
return rawMicroGetElementsByTagName.call(_this, key);
|
|
5914
|
+
// just script, not base
|
|
5902
5915
|
}
|
|
5903
|
-
else if (/^script
|
|
5916
|
+
else if (/^script$/i.test(key)) {
|
|
5904
5917
|
return rawMicroGetElementsByTagName.call(microDocument, key);
|
|
5905
5918
|
}
|
|
5906
5919
|
try {
|
|
@@ -6366,7 +6379,7 @@ class IframeSandbox {
|
|
|
6366
6379
|
this.escapeProperties = [];
|
|
6367
6380
|
// Properties escape to rawWindow, cleared when unmount
|
|
6368
6381
|
this.escapeKeys = new Set();
|
|
6369
|
-
//
|
|
6382
|
+
// Update the base.href when initial and each redirect
|
|
6370
6383
|
this.updateIframeBase = () => {
|
|
6371
6384
|
var _a;
|
|
6372
6385
|
// origin must be child app origin
|