Skip to content

Bug fix in update selector func #152

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
19 changes: 17 additions & 2 deletions src/scripts/Sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,24 @@ export default class Sitemap {
// selector is undefined when creating a new one and delete old one, if it exist
if (selector === undefined || selector.type !== selectorData.type) {
if (selector) {
this.deleteSelector(selector);
if (selector.canHaveChildSelectors()) {
//custom logic: we don’t delete children, but redefined them a parent
const children = this.selectors.filter(selectorFromList =>
selectorFromList.parentSelectors.includes(selector.uuid)
);
const newSelector = SelectorList.createSelector(selectorData);
children.forEach(child => {
const parentUuidIndex = child.parentSelectors.indexOf(selector.uuid);
child.parentSelectors[parentUuidIndex] = newSelector.uuid;
});
selector = newSelector;
} else {
this.deleteSelector(selector);
selector = SelectorList.createSelector(selectorData);
}
} else {
selector = SelectorList.createSelector(selectorData);
}
selector = SelectorList.createSelector(selectorData);
}

// update child selectors
Expand Down