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 +1 -1
- package/src/compiler/phases/3-transform/index.js +3 -6
- package/src/runtime/internal/client/for.js +2 -2
- package/src/runtime/internal/client/render.js +1 -1
- package/src/runtime/internal/client/runtime.js +5 -0
- package/tests/__snapshots__/composite.test.ripple.snap +14 -0
- package/tests/composite.test.ripple +17 -0
package/package.json
CHANGED
|
@@ -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 =
|
|
1596
|
+
const id = flush_node();
|
|
1597
1597
|
state.template.push(' ');
|
|
1598
|
-
|
|
1599
|
-
|
|
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} */ (
|
|
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
|
|
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
|
});
|