diff --git a/index.js b/index.js index b314a0e..6bf5223 100644 --- a/index.js +++ b/index.js @@ -89,9 +89,13 @@ export default function app (selector, routes = ['*']) { .then(res => res.text()) .then(res => { const doc = new window.DOMParser().parseFromString(res, 'text/html') + + const newRoot = doc.querySelector(selector) + if (! newRoot) return window.location.href = href + const c = [ doc, - doc.querySelector(selector).innerHTML + newRoot.innerHTML ] cache.set(href, c) cb && cb(c[0], c[1], route)