Skip to content

Commit

Permalink
* xover.Source.fetch - sets url to document if it hasn't been defined
Browse files Browse the repository at this point in the history
* XMLDocument.prototype.fetch - send url to fecth dispatcher
* source_handler - bug fixed for inherit xo-source
  • Loading branch information
uriel-online committed Jul 25, 2024
1 parent 708f658 commit 436b597
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3156,6 +3156,7 @@ xover.Source = function (tag) {
if (response instanceof Document) {
this.settings.stylesheets && this.settings.stylesheets.forEach(stylesheet => typeof (response.addStylesheet) == 'function' && response.addStylesheet(stylesheet));
}
response.url = response.url || url;
let fetch_event = new xover.listener.Event('fetch', { source: self, document: response, tag: tag_string, settings: this.settings, href: url.href, localpath: url.localpath, pathname: url.pathname, resource: url.resource, hash: url.hash, url }, self);
self.fetch_event = fetch_event;
window.top.dispatchEvent(fetch_event);
Expand Down Expand Up @@ -5780,12 +5781,13 @@ xover.modernize = async function (targetWindow) {
let old = context.cloneNode(true);
context.href = response.href;
context.url = response.url;
let url = context.url;
if (response instanceof Document || response instanceof DocumentFragment) {
context.replaceBy(response); //transfers all contents
} else {
context.replaceContent(response);
}
window.top.dispatchEvent(new xover.listener.Event(`fetch`, { tag: '', document: context, store: store, old: old, target: context }, context));
window.top.dispatchEvent(new xover.listener.Event(`fetch`, { url: response.url, href: response.url.href, tag: '', document: context, store: store, old: old, target: context }, context));
resolve(context);
}).catch(async (e) => {
if (!e) {
Expand Down Expand Up @@ -6109,7 +6111,7 @@ xover.modernize = async function (targetWindow) {
//let section = this.section || this;
//if (!(section instanceof HTMLElement && (this.hasAttribute("xo-stylesheet")))) return null;
let source = this.closest("[xo-source]");
if (source == 'inherit') {
if (source instanceof Element && source.getAttribute("xo-source") == 'inherit') {
return source.parentNode.source;
}
if (!(source instanceof HTMLElement)) return null;
Expand Down

0 comments on commit 436b597

Please sign in to comment.