ripple 0.2.26 → 0.2.27
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
|
@@ -744,7 +744,13 @@ const visitors = {
|
|
|
744
744
|
if (prop_statements === undefined) {
|
|
745
745
|
prop_statements = [];
|
|
746
746
|
}
|
|
747
|
-
|
|
747
|
+
if (path.has_default_value) {
|
|
748
|
+
const fallback = path.expression(b.id('__props'));
|
|
749
|
+
|
|
750
|
+
prop_statements.push(b.var(name, context.visit(fallback)));
|
|
751
|
+
} else {
|
|
752
|
+
prop_statements.push(b.var(name, b.member(b.id('__props'), key)));
|
|
753
|
+
}
|
|
748
754
|
} else if (binding !== null && path.has_default_value) {
|
|
749
755
|
if (prop_statements === undefined) {
|
|
750
756
|
prop_statements = [];
|
|
@@ -261,6 +261,24 @@ describe('composite components', () => {
|
|
|
261
261
|
expect(container.querySelectorAll('div')[1].textContent).toBe('123');
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
+
it('correctly handles default prop values #2', () => {
|
|
265
|
+
component Child({ foo = 456 }) {
|
|
266
|
+
<div>{foo}</div>
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
component App(props) {
|
|
270
|
+
let foo = 123;
|
|
271
|
+
|
|
272
|
+
<Child />
|
|
273
|
+
<Child {foo} />
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
render(App);
|
|
277
|
+
|
|
278
|
+
expect(container.querySelectorAll('div')[0].textContent).toBe('456');
|
|
279
|
+
expect(container.querySelectorAll('div')[1].textContent).toBe('123');
|
|
280
|
+
});
|
|
281
|
+
|
|
264
282
|
it('correctly handles no props', () => {
|
|
265
283
|
component Child(props) {
|
|
266
284
|
<div>{props.$foo}</div>
|