@micro-zoe/micro-app 1.0.0-rc.30 → 1.0.0-rc.31

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.30';
1
+ const version = '1.0.0-rc.31';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
@@ -822,8 +822,8 @@ class HTMLLoader {
822
822
  }
823
823
  }
824
824
 
825
- // common reg
826
- const rootSelectorREG = /(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/;
825
+ // common regular expression
826
+ // const rootSelectorREG = /(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/
827
827
  const bodySelectorREG = /(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;
828
828
  function parseError(msg, linkPath) {
829
829
  msg = linkPath ? `${linkPath} ${msg}` : msg;
@@ -850,6 +850,7 @@ class CSSParser {
850
850
  this.scopecssDisable = false; // use block comments /* scopecss-disable */ to disable scopecss in your file, and use /* scopecss-enable */ to enable scopecss
851
851
  this.scopecssDisableSelectors = []; // disable or enable scopecss for specific selectors
852
852
  this.scopecssDisableNextLine = false; // use block comments /* scopecss-disable-next-line */ to disable scopecss on a specific line
853
+ this.optionCssSelectors = []; // use this option to include specific selectors, so that they will be affected by scopecss ,like microApp.options.optionCss
853
854
  // https://developer.mozilla.org/en-US/docs/Web/API/CSSMediaRule
854
855
  this.mediaRule = this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/, '@media');
855
856
  // https://developer.mozilla.org/en-US/docs/Web/API/CSSSupportsRule
@@ -872,6 +873,8 @@ class CSSParser {
872
873
  this.prefix = prefix;
873
874
  this.baseURI = baseURI;
874
875
  this.linkPath = linkPath || '';
876
+ // fetch optionCss configure
877
+ this.optionCssSelectors = microApp.options.optionCss || [];
875
878
  this.matchRules();
876
879
  return isFireFox() ? decodeURIComponent(this.result) : this.result;
877
880
  }
@@ -879,6 +882,7 @@ class CSSParser {
879
882
  this.cssText = this.prefix = this.baseURI = this.linkPath = this.result = '';
880
883
  this.scopecssDisable = this.scopecssDisableNextLine = false;
881
884
  this.scopecssDisableSelectors = [];
885
+ this.optionCssSelectors = [];
882
886
  }
883
887
  // core action for match rules
884
888
  matchRules() {
@@ -936,6 +940,14 @@ class CSSParser {
936
940
  }
937
941
  return match;
938
942
  });
943
+ // Check if it is in the optionCss list
944
+ const isIsolationRoot = this.optionCssSelectors.some(includeSelector => {
945
+ // isolation-root is used to isolation the :root styles between base-app and sub-app
946
+ if (includeSelector === 'isolation-root')
947
+ return true;
948
+ return false;
949
+ });
950
+ const rootSelectorREG = isIsolationRoot ? /(^|\s+)(html)(?=[\s>~[.#:]+|$)/ : /(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/; // without root
939
951
  if (selector && !(this.scopecssDisableNextLine ||
940
952
  (this.scopecssDisable && (!this.scopecssDisableSelectors.length ||
941
953
  this.scopecssDisableSelectors.includes(selector))) ||