Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifying compositions by handler URI #123

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
47 changes: 27 additions & 20 deletions starcounter-include.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,34 @@
return this._renderCompositionChange(compositionProviderComposition, () => {
// convert string from view-model, to actual document fragment
const customComposition = this.stringToDocumentFragment(compositionProviderComposition);
var defaultViewHtmlsToBeRendered;

if (compositionProvider.ActualViewUris[0].hasOwnProperty("BlendingUri")) {
defaultViewHtmlsToBeRendered =
compositionProvider.ActualViewUris.filter(
x => !compositionProvider.ViewUris.includes(x.BlendingUri))
.map(x => x.ViewHtml);
} else {
defaultViewHtmlsToBeRendered = compositionProvider.ViewUris;
}

// append default compositions for views not covered by this composition
if (compositionProvider.ViewUris) {
const keys = Object.keys(this.viewModel);
for(let key of keys) {
const scoped = this.viewModel[key];
if (scoped && scoped.Html && compositionProvider.ViewUris.indexOf(scoped.Html) === -1) {
if (this.defaultComposition) {
this.template.scopedNodes.forEach((nodes) => {
if(nodes.scope === key) {
nodes.forEach((node) => appendComposition(customComposition, node));
}
});
}
else {
// BUG,TODO (tomalec): looks like a bug
// This means that if there *is* a custom composition, but it does not cover all views,
// and it happend that none of the views had a default composition,
// we would discard custom composition and use default -> fallback
return false;
}
const keys = Object.keys(this.viewModel);
for (let key of keys) {
const scoped = this.viewModel[key];
if (scoped && scoped.Html && defaultViewHtmlsToBeRendered.includes(scoped.Html)) {
if (this.defaultComposition) {
this.template.scopedNodes.forEach((nodes) => {
if (nodes.scope === key) {
nodes.forEach((node) => appendComposition(customComposition, node));
}
});
}
else {
// BUG,TODO (tomalec): looks like a bug
// This means that if there *is* a custom composition, but it does not cover all views,
// and it happend that none of the views had a default composition,
// we would discard custom composition and use default -> fallback
return false;
}
}
}
Expand Down