Inconsistent binding with "with" helper #2129

Closed
whitecolor opened this Issue Dec 9, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@whitecolor
Contributor

whitecolor commented Dec 9, 2015

2.3.5 latest:

<script id="app-template" type="text/stache">
<comp-one>
  {{#with someMap}}
  <comp-two {attr-a}="attrA" {attr-b}="attrB" {^attr-c}="attrC"></comp-two>
  {{/with}}
</comp-one>
</script>
console.clear()
can.Component.extend({
  tag: "comp-one",
  template: can.stache('<content/>'),
  viewModel: {
    attrC: "",
    attrB: "ATTRB",
    someMap: {attrC: ""}
  }
});

can.Component.extend({
  tag: "comp-two",
  viewModel: {
    attrC: "ATTRC"
  } 
});


var outer = new can.Map({
  attrA: "ATTRA"
})

$("body").prepend(
  can.view("app-template",outer) 
);

//Sould comp-on scope attrC be 'ATTRC'?
//Sould comp-on scope someMap.attrC be 'ATTRC'?

console.log('comp-one', $("comp-one").viewModel().serialize() )
console.log('comp-two', $("comp-two").viewModel().serialize() )

http://jsbin.com/fejabegore/1/edit?html,js,console,output

{^attr-c}="attrC" seem to have place attrC on the parent scope, in example it doesn't place it nor on viewModel, nor on someMap that is set using {{#with someMap}}

2.3.4 gives an error with such example:
http://jsbin.com/yalutefuye/1/edit?html,js,console,output

I believe if we using "with" in this case attrC should be placed on viewModel, but I'm not sure.

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Dec 9, 2015

Contributor

this is related to #2122 and I think this as well #2092

Contributor

whitecolor commented Dec 9, 2015

this is related to #2122 and I think this as well #2092

@daffl daffl added this to the 2.3.7 milestone Dec 14, 2015

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Dec 15, 2015

Contributor

Yeah, this should be fixed by #2139. Please re-open if you continue to find this.

Contributor

justinbmeyer commented Dec 15, 2015

Yeah, this should be fixed by #2139. Please re-open if you continue to find this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment