Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lively.morphic/components/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ export class StylePolicy {
});
const self = this;
buildSpec.onLoad = function () {
const policy = self;
const policy = self._preEstimatePolicy || self;
// do not trigger master setter, since that would cause an application
this.setProperty('master', policy);
policy.attach(this);
Expand Down Expand Up @@ -1501,12 +1501,10 @@ export class PolicyApplicator extends StylePolicy {
const synthesizedSpec = this.synthesizeSubSpec(submorphName, targetMorph, previousTarget, false);
if (obj.isEmpty(synthesizedSpec)) return;
if (synthesizedSpec.isPolicy) {
if (morphInScope._skipMasterReplacement) {
delete morphInScope._skipMasterReplacement;
return;
if (!morphInScope.master) {
morphInScope.setProperty('master', synthesizedSpec); // how can we carry over overridden props?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge regardless, but this comment makes me worry - is there a hidden footgun in this? If so, have you made a note of that somewhere/could you open a ticket, so that we can be sure to tackle this at some point and not forget?

If there is nothing to worry about, maybe just delete the comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we fix the issue mentioned in the comment by not setting the master if there is already one present. That way we avoid the issue of having to worry about carrying over the overridden props.

However what won't properly work now out of the box, is manually swapping out (via aMorph.master = ...) the master of a morph which comes with a set of other components for its submorphs. We don't support this modus of operation for masters since a while now anyways, since we do everything via component definitions and custom master states for swapping out masters.

But I will look and check if there is issues about this before merging.

synthesizedSpec.targetMorph = morphInScope;
}
morphInScope.setProperty('master', synthesizedSpec); // might be redundant
synthesizedSpec.targetMorph = morphInScope;
} else this.applySpecToMorph(morphInScope, synthesizedSpec); // this step enforces the master distribution

if (morphInScope !== targetMorph && morphInScope.master) {
Expand Down
5 changes: 3 additions & 2 deletions lively.morphic/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,9 @@ export class TilingLayout extends Layout {
for (let i = 0; i < containerSpec.submorphs.length; i++) {
let match; let fixedTotalExtent; let m = containerSpec.submorphs[i];
if (m.isPolicy) {
m = containerSpec.submorphs[i] = m.copy();
m = m.spec;
containerSpec.submorphs[i] = m.copy();
containerSpec.submorphs[i]._preEstimatePolicy = m;
m = containerSpec.submorphs[i].spec;
} else {
m = containerSpec.submorphs[i] = { ...m };
}
Expand Down