Open rluba opened 6 years ago
@rluba @EisenbergEffect
I think all the changes are good except using initiatedByBehavior
. By default checking that will also make it false positive for any custom element / custom attribute that doesn't actually require lifecycle. I think we have to introduce new property on If
metadata via:
const meta = metada.get(metdata.resource, If);
meta.behaviorRequiresLifecycle = true;
and check:
function behaviorRequiresLifecycle(instruction) {
let t = instruction.type;
let name = t.elementName !== null ? t.elementName : t.attributeName;
return lifecycleOptionalBehaviors.indexOf(name) === -1 && (t.handlesAttached || t.handlesBind || t.handlesCreated || t.handlesDetached || t.handlesUnbind)
|| t.viewFactory && viewsRequireLifecycle(t.viewFactory)
|| instruction.viewFactory && viewsRequireLifecycle(instruction.viewFactory)
|| instruction.type.behaviorRequiresLifecycle;
}
Note: naming is for discussion.
This is a crude attempt at fixing #356.
The fix for the
if
case was relatively straight-forward. But to disable the fast-pass for the "subview without lifecycle methods" case, I had to rely oninstruction.initiatedByBehavior
, because I couldn't find a better indicator.I just started working with Aurelia a few weeks ago, so I’m sure there’s a more elegant way that I couldn’t discover. Let me know what you think!