Use existing simpler method to resolve collisions

pull/8418/head
Nguyen Tran 4 years ago
parent 2943eefbbf
commit 3fdfdb4089

@ -127,7 +127,7 @@ export function unpack_destructuring({
if (property.computed) {
// e.g { [computedProperty]: ... }
const property_name = x`computed_property` as Identifier;
const property_name = component.get_unique_name('computed_property');
contexts.push({
type: 'ComputedProperty',

@ -12,7 +12,6 @@ import { Context } from '../../nodes/shared/Context';
import { Identifier, Literal, Node } from 'estree';
import { add_const_tags, add_const_tags_context } from './shared/add_const_tags';
import Expression from '../../nodes/shared/Expression';
import { resolve_computed_prop_conflicts } from '../../utils/resolve_computed_props';
type Status = 'pending' | 'then' | 'catch';
@ -99,8 +98,6 @@ class AwaitBlockBranch extends Wrapper {
}
render_get_context() {
resolve_computed_prop_conflicts(this.block, this.is_destructured ? this.value_contexts : [], this.has_consts(this.node) ? this.node.const_tags : []);
const props = this.is_destructured ? this.value_contexts.map(prop => {
if (prop.type === 'ComputedProperty') {
const expression = new Expression(this.renderer.component, this.node, this.has_consts(this.node) ? this.node.scope : null, prop.key);

@ -10,7 +10,6 @@ import { Identifier, Node } from 'estree';
import get_object from '../../utils/get_object';
import { add_const_tags, add_const_tags_context } from './shared/add_const_tags';
import Expression from '../../nodes/shared/Expression';
import { resolve_computed_prop_conflicts } from '../../utils/resolve_computed_props';
export class ElseBlockWrapper extends Wrapper {
node: ElseBlock;
@ -365,8 +364,6 @@ export default class EachBlockWrapper extends Wrapper {
this.else.fragment.render(this.else.block, null, x`#nodes` as Identifier);
}
resolve_computed_prop_conflicts(this.block, this.node.contexts, this.node.const_tags);
this.context_props = this.node.contexts.map(prop => {
if (prop.type === 'DestructuredVariable') {
const to_ctx = (name: string) => renderer.context_lookup.has(name) ? x`child_ctx[${renderer.context_lookup.get(name).index}]` : { type: 'Identifier', name } as Node;

@ -1,19 +0,0 @@
import { Context } from '../nodes/shared/Context';
import ConstTag from '../nodes/ConstTag';
import Block from '../render_dom/Block';
export function resolve_computed_prop_conflicts(block: Block, node_contexts: Context[], node_const_tags: ConstTag[]) {
node_contexts.forEach((context: Context) => {
if (context.type === 'ComputedProperty') {
context.property_name.name = block.get_unique_name('computed_prop').name;
}
});
node_const_tags.forEach((const_tag: ConstTag) => {
const_tag.contexts.forEach((context: Context) => {
if (context.type === 'ComputedProperty') {
context.property_name.name = block.get_unique_name('computed_prop').name;
}
});
});
}
Loading…
Cancel
Save