@micro-zoe/micro-app 1.0.0-rc.15 → 1.0.0-rc.17

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.15';
1
+ const version = '1.0.0-rc.17';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
@@ -911,8 +911,20 @@ class CSSParser {
911
911
  * 6. :where(.a, .b, .c) a {}
912
912
  * should be ==> micro-app[name=xxx] :where(.a, .b, .c) a {}
913
913
  */
914
- return m[0].replace(/(^|,[\n\s]*)([^,]+)/g, (_, separator, selector) => {
914
+ const attributeValues = {};
915
+ const matchRes = m[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1, p2) => {
916
+ const mock = `__mock_${p1}Value__`;
917
+ attributeValues[mock] = p2;
918
+ return match.replace(p2, mock);
919
+ });
920
+ return matchRes.replace(/(^|,[\n\s]*)([^,]+)/g, (_, separator, selector) => {
915
921
  selector = trim(selector);
922
+ selector = selector.replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g, (match, p1) => {
923
+ if (attributeValues[p1]) {
924
+ return match.replace(p1, attributeValues[p1]);
925
+ }
926
+ return match;
927
+ });
916
928
  if (selector && !(this.scopecssDisableNextLine ||
917
929
  (this.scopecssDisable && (!this.scopecssDisableSelectors.length ||
918
930
  this.scopecssDisableSelectors.includes(selector))) ||
@@ -941,7 +953,7 @@ class CSSParser {
941
953
  if (cssValue) {
942
954
  if (!this.scopecssDisableNextLine &&
943
955
  (!this.scopecssDisable || this.scopecssDisableSelectors.length)) {
944
- cssValue = cssValue.replace(/url\(["']?([^)"']+)["']?\)/gm, (all, $1) => {
956
+ cssValue = cssValue.replace(/url\((["']?)(.*?)\1\)/gm, (all, _, $1) => {
945
957
  if (/^((data|blob):|#|%23)/.test($1) || /^(https?:)?\/\//.test($1)) {
946
958
  return all;
947
959
  }
@@ -5573,16 +5585,18 @@ const proxy2RawDocumentMethods = [
5573
5585
  'prepend',
5574
5586
  ];
5575
5587
 
5588
+ const EXCLUDE_URL_PROTOCOLS = [
5589
+ 'blob:'
5590
+ ];
5576
5591
  // 重写 Worker 构造函数的类型
5577
5592
  const originalWorker = window.Worker;
5578
5593
  function isSameOrigin(url) {
5579
- if (url instanceof URL && url.protocol === 'blob:') {
5580
- // 如果 url 是 Blob URL,直接返回 true
5581
- return true;
5582
- }
5583
- // 检查 URL 是否与当前页面在同一个源
5584
5594
  try {
5585
- const parsedUrl = new URL(url);
5595
+ // 检查 URL 是否与当前页面在同一个源
5596
+ const parsedUrl = url instanceof URL ? url : new URL(url);
5597
+ if (EXCLUDE_URL_PROTOCOLS.includes(parsedUrl.protocol)) {
5598
+ return true;
5599
+ }
5586
5600
  return (parsedUrl.protocol === window.location.protocol &&
5587
5601
  parsedUrl.hostname === window.location.hostname &&
5588
5602
  parsedUrl.port === window.location.port);