ripple 0.2.69 → 0.2.70

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.69",
6
+ "version": "0.2.70",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -1593,13 +1593,10 @@ function transform_children(children, context) {
1593
1593
  if (expression.type === 'Literal') {
1594
1594
  state.template.push(escape_html(expression.value));
1595
1595
  } else {
1596
- const id = state.flush_node();
1596
+ const id = flush_node();
1597
1597
  state.template.push(' ');
1598
- state.init.push(
1599
- b.stmt(
1600
- b.assignment('=', b.member(b.call('_$_.child', id), b.id('nodeValue')), expression),
1601
- ),
1602
- );
1598
+ // avoid set_text overhead for single text nodes
1599
+ state.init.push(b.stmt(b.assignment('=', b.member(id, b.id('nodeValue')), expression)));
1603
1600
  }
1604
1601
  } else {
1605
1602
  // Handle Text nodes in fragments
@@ -1,7 +1,7 @@
1
1
  import { IS_CONTROLLED, IS_INDEXED } from '../../../constants.js';
2
2
  import { branch, destroy_block, destroy_block_children, render } from './blocks.js';
3
3
  import { FOR_BLOCK, TRACKED_ARRAY } from './constants.js';
4
- import { create_text } from './operations.js';
4
+ import { create_text, next_sibling } from './operations.js';
5
5
  import { active_block, set, tracked, untrack } from './runtime.js';
6
6
  import { array_from, is_array } from './utils.js';
7
7
 
@@ -40,7 +40,7 @@ function move(block, anchor) {
40
40
  return;
41
41
  }
42
42
  while (node !== end) {
43
- var next_node = /** @type {TemplateNode} */ (get_next_sibling(node));
43
+ var next_node = /** @type {TemplateNode} */ (next_sibling(node));
44
44
  anchor.before(node);
45
45
  node = next_node;
46
46
  }
@@ -15,7 +15,7 @@ import {
15
15
  import { get } from './runtime.js';
16
16
 
17
17
  export function set_text(text, value) {
18
- // For objects, we apply string coercion (which might make things like $state array references in the template reactive) before diffing
18
+ // For objects, we apply string coercion
19
19
  var str = value == null ? '' : typeof value === 'object' ? value + '' : value;
20
20
  // @ts-expect-error
21
21
  if (str !== (text.__t ??= text.nodeValue)) {
@@ -667,6 +667,11 @@ export function get_derived(computed) {
667
667
  * @param {Derived | Tracked} tracked
668
668
  */
669
669
  export function get(tracked) {
670
+ // reflect back the value if it's not boxed
671
+ if (!is_tracked_object(tracked)) {
672
+ return tracked;
673
+ }
674
+
670
675
  return (tracked.f & DERIVED) !== 0
671
676
  ? get_derived(/** @type {Derived} */ (tracked))
672
677
  : get_tracked(tracked);
@@ -21,3 +21,17 @@ exports[`composite components > correct handles passing through component props
21
21
 
22
22
  </div>
23
23
  `;
24
+
25
+ exports[`composite components > render simple text as children 1`] = `
26
+ <div>
27
+ <!---->
28
+ <button
29
+ class="my-button"
30
+ >
31
+ Click Me
32
+ <!---->
33
+ </button>
34
+ <!---->
35
+
36
+ </div>
37
+ `;
@@ -647,4 +647,21 @@ describe('composite components', () => {
647
647
 
648
648
  expect(container.textContent).toBe('Basic Component');
649
649
  });
650
+
651
+ it('render simple text as children', () => {
652
+ component App() {
653
+ let name = 'Click Me';
654
+
655
+ <Child
656
+ class="my-button"
657
+ >{name}</Child>;
658
+ }
659
+
660
+ component Child({children, ...rest}) {
661
+ <button {...rest}><children /></button>
662
+ }
663
+
664
+ render(App);
665
+ expect(container).toMatchSnapshot();
666
+ })
650
667
  });