mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-15 04:14:46 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
608fdb7533 | ||
|
|
80166b5a7d | ||
|
|
24b259f80b |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.0.10",
|
"version": "0.0.12",
|
||||||
"description": "Combat-ready apps, engineered by Svelte",
|
"description": "Combat-ready apps, engineered by Svelte",
|
||||||
"main": "connect.js",
|
"main": "connect.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import app from 'sapper/runtime/app.js';
|
import app from '__app__';
|
||||||
import { detachNode } from 'svelte/shared.js';
|
|
||||||
|
|
||||||
const target = document.querySelector('__selector__');
|
const target = document.querySelector('__selector__');
|
||||||
let component;
|
let component;
|
||||||
|
|
||||||
|
const detach = node => {
|
||||||
|
node.parentNode.removeChild(node);
|
||||||
|
};
|
||||||
|
|
||||||
app.init(url => {
|
app.init(url => {
|
||||||
if (url.origin !== window.location.origin) return;
|
if (url.origin !== window.location.origin) return;
|
||||||
|
|
||||||
@@ -25,9 +28,9 @@ app.init(url => {
|
|||||||
let end = document.querySelector('#sapper-head-end');
|
let end = document.querySelector('#sapper-head-end');
|
||||||
|
|
||||||
if (start && end) {
|
if (start && end) {
|
||||||
while (start.nextSibling !== end) detachNode(start.nextSibling);
|
while (start.nextSibling !== end) detach(start.nextSibling);
|
||||||
detachNode(start);
|
detach(start);
|
||||||
detachNode(end);
|
detach(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
target.innerHTML = '';
|
target.innerHTML = '';
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ module.exports = function create_app(src, dest, routes, options) {
|
|||||||
.join(' else ') + ' else return false;';
|
.join(' else ') + ' else return false;';
|
||||||
|
|
||||||
const main = template
|
const main = template
|
||||||
|
.replace('__app__', path.resolve(__dirname, '../runtime/app.js'))
|
||||||
.replace('__selector__', options.selector || 'main')
|
.replace('__selector__', options.selector || 'main')
|
||||||
.replace('// ROUTES', code);
|
.replace('// ROUTES', code);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user