You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Short summary: When using within with custom content that has {{if parent.method()}}, the parent reference is wrong when the inner component surrounds the content usage with {{if @content}}. The parent reference incorrectly resolves to the inner component under those two exact conditions, when it should resolve to the outer component.
I wrote failing test cases in Derby that demonstrate this bug, on the branch bug-within-if-content-parent: b4f45da
Say you have a picture-frame component that allows the inclusion of custom {{content}}. When using picture-frame from another component, say showcase, the default is that the "passed-in" custom content uses the context of showcase, where the custom content is declared.
It is possible to use the within attribute to have the custom content use the context internal to picture-frame, instead of the default of showcase. If the custom content also needs to use controller methods from the outer showcase, it can refer to them by {{parent.method()}}.
That all works fine, but there is a bug when both these are true:
The custom content uses a {{if parent.method()}} binding.
The text binding{{parent.method()}} works regardless of the second point.
picture-frame surrounds the content with {{if @content}} {{content}} {{/if}}.
{{if content}} (model path instead of attribute path) allows the first point to work fine.
Full example below.
showcase.html:
<index:><viewis="picture-frame" within>
{{frameInternalPath}}
<!-- This works fine in both cases -->
{{parent.showcaseName()}}
<!-- This breaks when picture-frame uses {{if @content}} -->
{{if parent.showcaseName()}} Uh oh! {{/if}}
</view>
Short summary: When using
within
with custom content that has{{if parent.method()}}
, theparent
reference is wrong when the inner component surrounds the content usage with{{if @content}}
. Theparent
reference incorrectly resolves to the inner component under those two exact conditions, when it should resolve to the outer component.I wrote failing test cases in Derby that demonstrate this bug, on the branch
bug-within-if-content-parent
:b4f45da
Say you have a
picture-frame
component that allows the inclusion of custom{{content}}
. When usingpicture-frame
from another component, sayshowcase
, the default is that the "passed-in" custom content uses the context ofshowcase
, where the custom content is declared.It is possible to use the
within
attribute to have the custom content use the context internal topicture-frame
, instead of the default ofshowcase
. If the custom content also needs to use controller methods from the outershowcase
, it can refer to them by{{parent.method()}}
.That all works fine, but there is a bug when both these are true:
{{if parent.method()}}
binding.{{parent.method()}}
works regardless of the second point.picture-frame
surrounds the content with{{if @content}} {{content}} {{/if}}
.{{if content}}
(model path instead of attribute path) allows the first point to work fine.Full example below.
showcase.html:
showcase.js:
picture-frame.html:
picture-frame.js:
The text was updated successfully, but these errors were encountered: