Skip to content

Commit

Permalink
Handle databindings with no common prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tate-CC committed Sep 19, 2023
1 parent 8cb65be commit 587838b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default (src) => {
const bookshop_path = bookshop_paths
.filter(({literal}) => !literal)
.reduce((acc, {path}) => {
if(!acc){
if(acc === null){
return path;
}
while(!path.startsWith(acc)){
Expand All @@ -155,11 +155,11 @@ export default (src) => {
}, null);
return $$render\`
\${(typeof $$maybeRenderHead !== 'undefined') ? $$maybeRenderHead($$result) : ''}
\${(${shouldDataBind} && bookshop_path) ? $$render\`<!--databinding:#\${$$render(bookshop_path)}-->\`: ''}
\${(${shouldDataBind} && bookshop_path !== null) ? $$render\`<!--databinding:#\${$$render(bookshop_path)}-->\`: ''}
\${(${shouldLiveRender} && ${component}.__bookshop_name) ? $$render\`<!--bookshop-live name(\${${component}.__bookshop_name}) params(\${$$render(params)})-->\`: ''}
\${'REPLACE_ME'}
\${(${shouldLiveRender} && ${component}.__bookshop_name) ? $$render\`<!--bookshop-live end-->\`: ''}
\${(${shouldDataBind} && bookshop_path) ? $$render\`<!--databindingend:#\${$$render(bookshop_path)}-->\`: ''}
\${(${shouldDataBind} && bookshop_path !== null) ? $$render\`<!--databindingend:#\${$$render(bookshop_path)}-->\`: ''}
\`})()`;

let template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,14 @@ export default (src, componentName) => {
const bookshop_path = bookshop_paths
.filter(({literal}) => !literal)
.reduce((acc, {path}) => {
if(acc === null){
return path;
}
while(!path.startsWith(acc)){
acc = acc.replace(/\\.?[^.]*$/, '');
}
return acc;
}, bookshop_paths[0]?.path);
}, null);
return REPLACE_ME;
})()`
.replace(/(^\s*)|(\s*$)/gm, "")
Expand Down

0 comments on commit 587838b

Please sign in to comment.