Skip to content

Commit

Permalink
fix template_scope of undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Jan 2, 2021
1 parent 200d452 commit b74b445
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/compiler/compile/nodes/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import Node from './shared/Node';
import Expression from './shared/Expression';
import Component from '../Component';
import TemplateScope from './shared/TemplateScope';
import { TemplateNode } from '../../interfaces';
import { Directive } from '../../interfaces';

export default class Action extends Node {
type: 'Action';
name: string;
expression: Expression;
uses_context: boolean;
template_scope: TemplateScope;

constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode) {
constructor(component: Component, parent: Node, scope: TemplateScope, info: Directive) {
super(component, parent, scope, info);

const object = info.name.split('.')[0];
Expand All @@ -23,6 +24,8 @@ export default class Action extends Node {
? new Expression(component, this, scope, info.expression)
: null;

this.template_scope = scope;

this.uses_context = this.expression && this.expression.uses_context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function add_actions(
}

export function add_action(block: Block, target: string, action: Action) {
const { expression } = action;
const { expression, template_scope } = action;
let snippet;
let dependencies;

Expand All @@ -29,7 +29,7 @@ export function add_action(block: Block, target: string, action: Action) {

const [obj, ...properties] = action.name.split('.');

const fn = is_contextual(action.component, action.expression.template_scope, obj)
const fn = is_contextual(action.component, template_scope, obj)
? block.renderer.reference(obj)
: obj;

Expand Down

0 comments on commit b74b445

Please sign in to comment.