Skip to content

functions in nested objects are not bound to that object, resulting in inconsistent behavior #1860

Open
@vassudanagunta

Description

@vassudanagunta

Given the following input:

const context = {
    nested: {
        awesome: function () {
            return this.more;
        },
        more: 'Deeply awesome'
    },
    more: 'More awesome'
}

the following template:

{{nested.awesome}}

yields 'More awesome', whereas the equivalent Javascript:

context.nested.awesome()

yields 'Deeply awesome'

More importantly,

{{#with nested}}
    {{awesome}}
{{/with}}

also yields 'Deeply awesome'.

Here is the js-fiddle demonstrating this

PR submitted with a failing test case: #1861.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions