Skip to content

Register bindings on nearest parent element (or maybe not) #65

@m-mujica

Description

@m-mujica

For a template like:

<span>{{count}}</span>

can-view-live listens to the parent node, span (for legacy reasons, jQuery ignored textNodes) but technically the binding appears in span.firstChild.

This means, if you want to debug the template, you have to pass in the parent node, like:

debug.logWhatChangesMe(spanElement);  // current behavior, intuitive I think?

Should we make it so you have to do this instead?

debug.logWhatChangesMe(spanElement.firstChild);  // technically correct

If that's true, what happens with templates that have no parent node? E.g:

var frag = stache("{{foo}}");

Currently, can-view-live listens on the document fragment, so you'd have to do something like this to debug it:

var frag = stache("{{foo}}")

// this does not work currently, because DocumentFragment 
// does not implement the `can.getValueDependencies` symbol
debug.logWhatChangesMe(frag);

Note: it's also possible to have lists without parent node (other than the document fragment itself)

{{#if foo}} {{#each items}} {{ this }} {{/each}} {{/if}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions