|
|
@@ -11,6 +11,433 @@ export function render(_ctx) {
|
|
|
}"
|
|
|
`;
|
|
|
|
|
|
+exports[`compiler: expression > cache expressions > TSNonNullExpression 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _obj = _ctx.obj
|
|
|
+ _setProp(n0, "id", _obj!.foo + _obj!.bar)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > cache variable used in both property shorthand and normal binding 1`] = `
|
|
|
+"import { setStyle as _setStyle, setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _color = _ctx.color
|
|
|
+ _setStyle(n0, {color: _color})
|
|
|
+ _setProp(n0, "id", _color)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > dynamic key bindings with expressions 1`] = `
|
|
|
+"import { setDynamicProps as _setDynamicProps, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _key = _ctx.key
|
|
|
+ _setDynamicProps(n0, [{ [_key+1]: _ctx.foo[_key+1]() }])
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > dynamic property access 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _obj = _ctx.obj
|
|
|
+ _setProp(n0, "id", _obj[1][_ctx.baz] + _obj.bar)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > dynamic property access with parentheses 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo_bar = _ctx.foo[_ctx.bar]
|
|
|
+ _setProp(n0, "x", (_foo_bar).x)
|
|
|
+ _setProp(n0, "bar", (_foo_bar))
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > function calls with arguments 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ const n2 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ const _bar = _ctx.bar
|
|
|
+ const _foo_bar_baz = _foo[_bar(_ctx.baz)]
|
|
|
+ _setProp(n0, "id", _foo_bar_baz)
|
|
|
+ _setProp(n1, "id", _foo_bar_baz)
|
|
|
+ _setProp(n2, "id", _bar() + _foo)
|
|
|
+ })
|
|
|
+ return [n0, n1, n2]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > not cache variable and member expression with the same name 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => _setProp(n0, "id", _ctx.bar + _ctx.obj.bar))
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > not cache variable in function expression 1`] = `
|
|
|
+"import { setDynamicProps as _setDynamicProps, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => _setDynamicProps(n0, [{ foo: bar => _ctx.foo = bar }]))
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > not cache variable only used in property shorthand 1`] = `
|
|
|
+"import { setStyle as _setStyle, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => _setStyle(n0, {color: _ctx.color}))
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > object property chain access 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _obj = _ctx.obj
|
|
|
+ const _obj_foo_baz_obj_bar = _obj['foo']['baz'] + _obj.bar
|
|
|
+ _setProp(n0, "id", _obj_foo_baz_obj_bar)
|
|
|
+ _setProp(n1, "id", _obj_foo_baz_obj_bar)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > object property name substring cases 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _p = _ctx.p
|
|
|
+ const _p_title = _p.title
|
|
|
+ _setProp(n0, "id", _p_title + _p.titles + _p_title)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > optional chaining 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _obj = _ctx.obj
|
|
|
+ _setProp(n0, "id", _obj?.foo + _obj?.bar)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > repeated expression in expressions 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ const n2 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ const _foo_bar = _foo + _ctx.bar
|
|
|
+ _setProp(n0, "id", _foo_bar)
|
|
|
+ _setProp(n1, "id", _foo_bar)
|
|
|
+ _setProp(n2, "id", _foo + _foo_bar)
|
|
|
+ })
|
|
|
+ return [n0, n1, n2]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > repeated expressions 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo_bar = _ctx.foo + _ctx.bar
|
|
|
+ _setProp(n0, "id", _foo_bar)
|
|
|
+ _setProp(n1, "id", _foo_bar)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > repeated variable in expressions 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ _setProp(n0, "id", _foo + _foo + _ctx.bar)
|
|
|
+ _setProp(n1, "id", _foo)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > repeated variables 1`] = `
|
|
|
+"import { setClass as _setClass, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ _setClass(n0, _foo)
|
|
|
+ _setClass(n1, _foo)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > shared member root 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ _setProp(n0, "id", _foo.bar)
|
|
|
+ _setProp(n1, "id", _foo.baz)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > shared member root with TSNonNullExpression 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ _setProp(n0, "id", _foo!.bar)
|
|
|
+ _setProp(n1, "id", _foo!.baz)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should cache method call with same arguments 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _msg_replace_1_2 = _ctx.msg.replace('1', '2')
|
|
|
+ _setProp(n0, "id", _msg_replace_1_2)
|
|
|
+ _setProp(n1, "id", _msg_replace_1_2)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should cache optional call expression with same arguments 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _obj_foo_bar = _ctx.obj[_ctx.foo?.(_ctx.bar)]
|
|
|
+ _setProp(n0, "id", _obj_foo_bar)
|
|
|
+ _setProp(n1, "id", _obj_foo_bar)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache Date.now() call expressions 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ _setProp(n0, "id", Date.now())
|
|
|
+ _setProp(n1, "id", Date.now())
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache globally allowed identifier as variable 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ _setProp(n0, "id", String(_ctx.foo))
|
|
|
+ _setProp(n1, "id", String(_ctx.bar))
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache globally allowed identifier call expressions 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ _setProp(n0, "id", Math.random())
|
|
|
+ _setProp(n1, "id", Math.random())
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache member expression containing globally allowed call 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ _setProp(n0, "id", _ctx.obj[Math.random()])
|
|
|
+ _setProp(n1, "id", _ctx.obj[Math.random()])
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache method call with different arguments 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _msg = _ctx.msg
|
|
|
+ _setProp(n0, "id", _msg.replace('1', '2'))
|
|
|
+ _setProp(n1, "id", _msg.replace('1', '3'))
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache mixed expression with globally allowed call 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>")
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ const n1 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ _setProp(n0, "id", Math.random() + _ctx.foo)
|
|
|
+ _setProp(n1, "id", Math.random() + _ctx.foo)
|
|
|
+ })
|
|
|
+ return [n0, n1]
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > should not cache update expression 1`] = `
|
|
|
+"import { child as _child, txt as _txt, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div> ", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n1 = t0()
|
|
|
+ const n0 = _child(n1)
|
|
|
+ const x1 = _txt(n1)
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _foo = _ctx.foo
|
|
|
+ _setProp(n1, "id", String(_foo.id++))
|
|
|
+ _setProp(n1, "foo", _foo)
|
|
|
+ _setProp(n1, "bar", _ctx.bar++)
|
|
|
+ _setText(n0, _toDisplayString(String(_foo.id++)) + " " + _toDisplayString(_foo) + " " + _toDisplayString(_ctx.bar))
|
|
|
+ _setText(x1, _toDisplayString(String(_foo.id++)) + " " + _toDisplayString(_foo) + " " + _toDisplayString(_ctx.bar))
|
|
|
+ })
|
|
|
+ return n1
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
+exports[`compiler: expression > cache expressions > variable name substring edge cases 1`] = `
|
|
|
+"import { setProp as _setProp, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
+const t0 = _template("<div>", true)
|
|
|
+
|
|
|
+export function render(_ctx) {
|
|
|
+ const n0 = t0()
|
|
|
+ _renderEffect(() => {
|
|
|
+ const _title = _ctx.title
|
|
|
+ _setProp(n0, "id", _title + _ctx.titles + _title)
|
|
|
+ })
|
|
|
+ return n0
|
|
|
+}"
|
|
|
+`;
|
|
|
+
|
|
|
exports[`compiler: expression > empty interpolation 1`] = `
|
|
|
"import { template as _template } from 'vue';
|
|
|
const t0 = _template(" ")
|
|
|
@@ -79,23 +506,3 @@ export function render(_ctx, $props, $emit, $attrs, $slots) {
|
|
|
return n0
|
|
|
}"
|
|
|
`;
|
|
|
-
|
|
|
-exports[`compiler: expression > update expression 1`] = `
|
|
|
-"import { child as _child, txt as _txt, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
|
|
|
-const t0 = _template("<div> ", true)
|
|
|
-
|
|
|
-export function render(_ctx) {
|
|
|
- const n1 = t0()
|
|
|
- const n0 = _child(n1)
|
|
|
- const x1 = _txt(n1)
|
|
|
- _renderEffect(() => {
|
|
|
- const _foo = _ctx.foo
|
|
|
- _setProp(n1, "id", String(_foo.id++))
|
|
|
- _setProp(n1, "foo", _foo)
|
|
|
- _setProp(n1, "bar", _ctx.bar++)
|
|
|
- _setText(n0, _toDisplayString(String(_foo.id++)) + " " + _toDisplayString(_foo) + " " + _toDisplayString(_ctx.bar))
|
|
|
- _setText(x1, _toDisplayString(String(_foo.id++)) + " " + _toDisplayString(_foo) + " " + _toDisplayString(_ctx.bar))
|
|
|
- })
|
|
|
- return n1
|
|
|
-}"
|
|
|
-`;
|