lib/generators/pakyow/app/templates/public/scripts/ring/components/navigator.js in pakyow-0.10.2 vs lib/generators/pakyow/app/templates/public/scripts/ring/components/navigator.js in pakyow-0.11.0

- old
+ new

@@ -78,10 +78,13 @@ if (!window.socket) { document.location = uri; return; } + uri = uri.replace(document.location.origin, ''); + pw.component.broadcast('navigator:change', { uri: uri }); + if (state.context) { state.r_uri = document.location.pathname + '#:' + state.context + '/' + uri; window.context = { _state: state, @@ -133,18 +136,19 @@ pw.component.broadcast(state.context + ':navigator:enter', payload); } else { var body = payload.body[0]; if (body.match(/<title>/)) { - document.title = body.split(/<title>/)[1].split('</title>')[0]; + var title = body.split(/<title>/)[1].split('</title>')[0]; + document.querySelector('title').innerHTML = title; } - if (body.match(/<body [^>]*>/)) { - document.body.innerHTML = body.split(/<body [^>]*>/)[1].split('</body>')[0]; - } else { - document.body.innerHTML = body; - } + var doc = document.documentElement.cloneNode(); + doc.innerHTML = body; + document.body.innerHTML = doc.querySelector('body').innerHTML; pw.component.findAndInit(document.querySelectorAll('body')[0]); + + document.body.scrollTop = document.documentElement.scrollTop = 0; } }); }