rip-lang 3.13.87 → 3.13.88

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.87-blue.svg" alt="Version"></a>
12
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/version-3.13.88-blue.svg" alt="Version"></a>
13
13
  <a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
14
14
  <a href="#"><img src="https://img.shields.io/badge/tests-1%2C436%2F1%2C436-brightgreen.svg" alt="Tests"></a>
15
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.13.87",
3
+ "version": "3.13.88",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/compiler.js CHANGED
@@ -896,7 +896,10 @@ export class CodeGenerator {
896
896
  targetCode = this.generate(target, 'value');
897
897
  }
898
898
 
899
+ const prevComponentName = this._componentName;
900
+ if (this.is(value, 'component') && (typeof target === 'string' || target instanceof String)) this._componentName = str(target);
899
901
  let valueCode = this.generate(value, 'value');
902
+ this._componentName = prevComponentName;
900
903
  let isObjLit = this.is(value, 'object');
901
904
  if (!isObjLit) valueCode = this.unwrap(valueCode);
902
905
 
@@ -2067,11 +2070,23 @@ export class CodeGenerator {
2067
2070
  let [decl] = rest;
2068
2071
  if (this.options.skipExports) {
2069
2072
  if (Array.isArray(decl) && decl.every(i => typeof i === 'string')) return '';
2070
- if (this.is(decl, '=')) return `const ${decl[1]} = ${this.generate(decl[2], 'value')}`;
2073
+ if (this.is(decl, '=')) {
2074
+ const prev = this._componentName;
2075
+ if (this.is(decl[2], 'component')) this._componentName = str(decl[1]);
2076
+ const result = `const ${decl[1]} = ${this.generate(decl[2], 'value')}`;
2077
+ this._componentName = prev;
2078
+ return result;
2079
+ }
2071
2080
  return this.generate(decl, 'statement');
2072
2081
  }
2073
2082
  if (Array.isArray(decl) && decl.every(i => typeof i === 'string')) return `export { ${decl.join(', ')} }`;
2074
- if (this.is(decl, '=')) return `export const ${decl[1]} = ${this.generate(decl[2], 'value')}`;
2083
+ if (this.is(decl, '=')) {
2084
+ const prev = this._componentName;
2085
+ if (this.is(decl[2], 'component')) this._componentName = str(decl[1]);
2086
+ const result = `export const ${decl[1]} = ${this.generate(decl[2], 'value')}`;
2087
+ this._componentName = prev;
2088
+ return result;
2089
+ }
2075
2090
  return `export ${this.generate(decl, 'statement')}`;
2076
2091
  }
2077
2092
 
@@ -3294,6 +3309,7 @@ export class Compiler {
3294
3309
  skipPreamble: this.options.skipPreamble,
3295
3310
  skipRuntimes: this.options.skipRuntimes,
3296
3311
  skipExports: this.options.skipExports,
3312
+ skipDataPart: this.options.skipDataPart,
3297
3313
  stubComponents: this.options.stubComponents,
3298
3314
  reactiveVars: this.options.reactiveVars,
3299
3315
  sourceMap,
package/src/components.js CHANGED
@@ -1267,6 +1267,10 @@ export function installComponentSupport(CodeGenerator, Lexer) {
1267
1267
  this._createLines.push(`${elVar}.id = '${id}';`);
1268
1268
  }
1269
1269
 
1270
+ if (this._componentName && this._elementCount === 1 && !this._factoryMode && !this.options.skipDataPart) {
1271
+ this._createLines.push(`${elVar}.setAttribute('data-part', '${this._componentName}');`);
1272
+ }
1273
+
1270
1274
  const autoWireClaimed = this._claimAutoWire(elVar);
1271
1275
 
1272
1276
  // Defer class emission when selector classes exist so class: attributes merge