Skip to content

Commit

Permalink
* xover.site.setter - reallocated section render trigger
Browse files Browse the repository at this point in the history
* xover.site.pushState - added section render trigger
* xover.site.replaceState - added section render trigger
  • Loading branch information
uriel-online committed Aug 11, 2024
1 parent 6283233 commit e88c55c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2044,13 +2044,13 @@ xover.site = new Proxy(Object.assign({}, history.state), {
history.state[key] = new_value;
if (['active', 'seed'].includes(key)) {
let current_hash = location.hash;
xover.site.sections.map(el => [el, el.stylesheet]).filter(([el, stylesheet]) => stylesheet && stylesheet.selectSingleNode(`//xsl:stylesheet/xsl:param[starts-with(@name,'site:${key}')]`)).forEach(([el]) => el.render());
let hash = [xover.manifest.getSettings(self['active'], 'hash').pop(), self['active'], location.hash, ''].coalesce();
history.replaceState(Object.assign({}, history.state), {}, location.pathname + location.search + hash);
if (current_hash != location.hash) {
window.dispatchEvent(new Event('hashchange'));
}
}
xover.site.sections.map(el => [el, el.stylesheet]).filter(([el, stylesheet]) => stylesheet && stylesheet.selectSingleNode(`//xsl:stylesheet/xsl:param[starts-with(@name,'site:${key}')]`)).forEach(([el]) => el.render());
if (key === 'seed') self['active'] = new_value;
for (let [subscriber] of xover.subscribers.site[key]) {
subscriber.evaluate()
Expand Down Expand Up @@ -2480,13 +2480,19 @@ Object.defineProperty(xover.site, 'seed', {
Object.defineProperty(xover.site, 'pushState', {
value: function (state = {}, href = location.hash) {
history.pushState(Object.merge.call({}, { position: history.length - 1 }, state), {}, href);
for (let key of Object.keys(state)) {
xover.site.sections.map(el => [el, el.stylesheet]).filter(([el, stylesheet]) => stylesheet && stylesheet.selectSingleNode(`//xsl:stylesheet/xsl:param[starts-with(@name,'site:${key}')]`)).forEach(([el]) => el.render());
}
}
, enumerable: true, writable: false, configurable: false
});

Object.defineProperty(xover.site, 'replaceState', {
value: function (state = {}, hash = location.hash) {
history.replaceState(Object.merge.call(history.state, state), {}, hash);
for (let key of Object.keys(state)) {
xover.site.sections.map(el => [el, el.stylesheet]).filter(([el, stylesheet]) => stylesheet && stylesheet.selectSingleNode(`//xsl:stylesheet/xsl:param[starts-with(@name,'site:${key}')]`)).forEach(([el]) => el.render());
}
}
, enumerable: true, writable: false, configurable: false
});
Expand Down

0 comments on commit e88c55c

Please sign in to comment.