@torpor/view 0.1.3 → 0.1.5

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/dist/compile.js CHANGED
@@ -2057,16 +2057,20 @@ function buildStyles(style, styleHash) {
2057
2057
  }
2058
2058
  var globalStyleRegex = /\:global\((.+)\)/;
2059
2059
  function buildStyleBlock(block, b, styleHash) {
2060
- const selectors = block.selector.split(/([\s*,>+~])/).filter((s) => !!s.trim()).map((s) => {
2061
- if (s.length === 1 && "*,>+~".includes(s)) {
2062
- return s;
2063
- } else if (globalStyleRegex.test(s)) {
2064
- return s.match(globalStyleRegex)[1];
2065
- } else {
2066
- return `${s}.torp-${styleHash}`;
2067
- }
2068
- });
2069
- b.append(`${selectors.join(" ")} {`);
2060
+ if (block.selector.startsWith("@")) {
2061
+ b.append(`${block.selector} {`);
2062
+ } else {
2063
+ const selectors = block.selector.split(/([\s*,>+~])/).filter((s) => !!s.trim()).map((s) => {
2064
+ if (s.length === 1 && "*,>+~".includes(s)) {
2065
+ return s;
2066
+ } else if (globalStyleRegex.test(s)) {
2067
+ return s.match(globalStyleRegex)[1];
2068
+ } else {
2069
+ return `${s}.torp-${styleHash}`;
2070
+ }
2071
+ });
2072
+ b.append(`${selectors.join(" ")} {`);
2073
+ }
2070
2074
  for (let attribute of block.attributes) {
2071
2075
  buildStyleAttribute(attribute, b);
2072
2076
  }
@@ -3640,6 +3644,11 @@ function parseStyleAttribute(status) {
3640
3644
  };
3641
3645
  }
3642
3646
 
3647
+ // src/compile/types/nodes/isComponentNode.ts
3648
+ function isComponentNode(node) {
3649
+ return node.type === "component";
3650
+ }
3651
+
3643
3652
  // src/compile/types/nodes/isParentNode.ts
3644
3653
  function isParentNode(node) {
3645
3654
  return "children" in node;
@@ -3658,7 +3667,7 @@ function scopeStyles(status) {
3658
3667
  }
3659
3668
  }
3660
3669
  function scopeStylesOnNode(node, selectors) {
3661
- if (isElementNode(node)) {
3670
+ if (isElementNode(node) || isComponentNode(node)) {
3662
3671
  let scopeStyles2 = selectors.includes(node.tagName);
3663
3672
  if (!scopeStyles2) {
3664
3673
  for (let a of node.attributes) {