Merge pull request #811 from sveltejs/gh-797

compile to custom element
pull/813/head
Rich Harris 8 years ago committed by GitHub
commit 7c29defef4

@ -11,6 +11,7 @@
],
"scripts": {
"test": "mocha --opts mocha.opts",
"quicktest": "mocha --opts mocha.opts",
"precoverage": "export COVERAGE=true && nyc mocha --opts mocha.coverage.opts",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"codecov": "codecov",

@ -337,7 +337,7 @@ export default class Stylesheet {
}
}
render(cssOutputFilename: string) {
render(cssOutputFilename: string, shouldTransformSelectors: boolean) {
if (!this.hasStyles) {
return { css: null, cssMap: null };
}
@ -351,9 +351,11 @@ export default class Stylesheet {
}
});
this.children.forEach((child: (Atrule|Rule)) => {
child.transform(code, this.id, this.keyframes, this.cascade);
});
if (shouldTransformSelectors) {
this.children.forEach((child: (Atrule|Rule)) => {
child.transform(code, this.id, this.keyframes, this.cascade);
});
}
let c = 0;
this.children.forEach(child => {

@ -15,7 +15,7 @@ import clone from '../utils/clone';
import DomBlock from './dom/Block';
import SsrBlock from './server-side-rendering/Block';
import Stylesheet from '../css/Stylesheet';
import { Node, GenerateOptions, Parsed, CompileOptions } from '../interfaces';
import { Node, GenerateOptions, Parsed, CompileOptions, CustomElementOptions } from '../interfaces';
const test = typeof global !== 'undefined' && global.__svelte_test;
@ -31,6 +31,10 @@ export default class Generator {
name: string;
options: CompileOptions;
customElement: CustomElementOptions;
tag: string;
props: string[];
defaultExport: Node[];
imports: Node[];
helpers: Set<string>;
@ -100,6 +104,19 @@ export default class Generator {
this.parseJs();
this.name = this.alias(name);
if (options.customElement === true) {
this.customElement = {
tag: this.tag,
props: this.props // TODO autofill this in
}
} else {
this.customElement = options.customElement;
}
if (this.customElement && !this.customElement.tag) {
throw new Error(`No tag name specified`); // TODO better error
}
}
addSourcemapLocations(node: Node) {
@ -372,7 +389,9 @@ export default class Generator {
addString(finalChunk);
addString('\n\n' + getOutro(format, name, options, this.imports));
const { css, cssMap } = this.stylesheet.render(options.cssOutputFilename);
const { css, cssMap } = this.customElement ?
{ css: null, cssMap: null } :
this.stylesheet.render(options.cssOutputFilename, true);
return {
ast: this.ast,
@ -554,6 +573,16 @@ export default class Generator {
templateProperties.ondestroy = templateProperties.onteardown;
}
if (templateProperties.tag) {
this.tag = templateProperties.tag.value.value;
removeObjectKey(this.code, defaultExport.declaration, 'tag');
}
if (templateProperties.props) {
this.props = templateProperties.props.value.elements.map((element: Node) => element.value);
removeObjectKey(this.code, defaultExport.declaration, 'props');
}
// now that we've analysed the default export, we can determine whether or not we need to keep it
let hasDefaultExport = !!defaultExport;
if (defaultExport && defaultExport.declaration.properties.length === 0) {

@ -111,18 +111,17 @@ export default function dom(
`);
}
if (generator.stylesheet.hasStyles && options.css !== false) {
const { css, cssMap } = generator.stylesheet.render(options.filename);
const textContent = stringify(options.dev ?
`${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` :
css, { onlyEscapeAtSymbol: true });
const { css, cssMap } = generator.stylesheet.render(options.filename, !generator.customElement);
const styles = generator.stylesheet.hasStyles && stringify(options.dev ?
`${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` :
css, { onlyEscapeAtSymbol: true });
if (styles && generator.options.css !== false && !generator.customElement) {
builder.addBlock(deindent`
function @add_css () {
var style = @createElement( 'style' );
style.id = '${generator.stylesheet.id}-style';
style.textContent = ${textContent};
style.textContent = ${styles};
@appendNode( style, document.head );
}
`);
@ -143,95 +142,156 @@ export default function dom(
? `@proto `
: deindent`
{
${['destroy', 'get', 'fire', 'observe', 'on', 'set', '_set', 'teardown']
${['destroy', 'get', 'fire', 'observe', 'on', 'set', 'teardown', '_set', '_mount', '_unmount']
.map(n => `${n}: @${n === 'teardown' ? 'destroy' : n}`)
.join(',\n')}
}`;
// TODO deprecate component.teardown()
builder.addBlock(deindent`
function ${name} ( options ) {
${options.dev &&
`if ( !options || (!options.target && !options._root) ) throw new Error( "'target' is a required option" );`}
this.options = options;
${generator.usesRefs && `this.refs = {};`}
this._state = ${templateProperties.data
? `@assign( @template.data(), options.data )`
: `options.data || {}`};
${generator.metaBindings}
${computations.length && `this._recompute( {}, this._state, {}, true );`}
${options.dev &&
Array.from(generator.expectedProperties).map(
prop =>
`if ( !( '${prop}' in this._state ) ) console.warn( "Component was created without expected data property '${prop}'" );`
)}
${generator.bindingGroups.length &&
`this._bindingGroups = [ ${Array(generator.bindingGroups.length)
.fill('[]')
.join(', ')} ];`}
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
const constructorBody = deindent`
${options.dev && !generator.customElement &&
`if ( !options || (!options.target && !options._root) ) throw new Error( "'target' is a required option" );`}
this.options = options;
${generator.usesRefs && `this.refs = {};`}
this._state = ${templateProperties.data
? `@assign( @template.data(), options.data )`
: `options.data || {}`};
${generator.metaBindings}
${computations.length && `this._recompute( {}, this._state, {}, true );`}
${options.dev &&
Array.from(generator.expectedProperties).map(
prop =>
`if ( !( '${prop}' in this._state ) ) console.warn( "Component was created without expected data property '${prop}'" );`
)}
${generator.bindingGroups.length &&
`this._bindingGroups = [ ${Array(generator.bindingGroups.length)
.fill('[]')
.join(', ')} ];`}
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
${templateProperties.ondestroy && `this._handlers.destroy = [@template.ondestroy]`}
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
${generator.slots.size && `this._slotted = options.slots || {};`}
${generator.customElement ?
deindent`
this.attachShadow({ mode: 'open' });
${css && `this.shadowRoot.innerHTML = \`<style>${options.dev ? `${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` : css}</style>\`;`}
` :
(generator.stylesheet.hasStyles && options.css !== false &&
`if ( !document.getElementById( '${generator.stylesheet.id}-style' ) ) @add_css();`)
}
this._handlers = Object.create( null );
${templateProperties.ondestroy && `this._handlers.destroy = [@template.ondestroy]`}
${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`}
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
${generator.slots.size && `this._slotted = options.slots || {};`}
${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent`
if ( !options._root ) {
this._oncreate = [${templateProperties.oncreate && `oncreate`}];
${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`}
${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`}
} ${templateProperties.oncreate && deindent`
else {
this._root._oncreate.push(oncreate);
}
`}
`}
${generator.stylesheet.hasStyles &&
options.css !== false &&
`if ( !document.getElementById( '${generator.stylesheet.id}-style' ) ) @add_css();`}
${generator.slots.size && `this.slots = {};`}
${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`}
this._fragment = @create_main_fragment( this._state, this );
${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent`
if ( !options._root ) {
this._oncreate = [${templateProperties.oncreate && `oncreate`}];
${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`}
${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`}
} ${templateProperties.oncreate && deindent`
else {
this._root._oncreate.push(oncreate);
}
if ( options.target ) {
${generator.hydratable
? deindent`
var nodes = @children( options.target );
options.hydrate ? this._fragment.claim( nodes ) : this._fragment.create();
nodes.forEach( @detachNode );
` :
deindent`
${options.dev && `if ( options.hydrate ) throw new Error( 'options.hydrate only works if the component was compiled with the \`hydratable: true\` option' );`}
this._fragment.create();
`}
${generator.customElement ?
`this._mount( options.target, options.anchor || null );` :
`this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, options.anchor || null );`}
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
${generator.hasComponents && `this._lock = true;`}
${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`}
${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`}
${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`}
${generator.hasComponents && `this._lock = false;`}
`}
}
`;
if (generator.customElement) {
const props = generator.props || Array.from(generator.expectedProperties);
builder.addBlock(deindent`
class ${name} extends HTMLElement {
constructor(options = {}) {
super();
${constructorBody}
}
static get observedAttributes() {
return ${JSON.stringify(props)};
}
${generator.slots.size && `this.slots = {};`}
this._fragment = @create_main_fragment( this._state, this );
if ( options.target ) {
${generator.hydratable
? deindent`
var nodes = @children( options.target );
options.hydrate ? this._fragment.claim( nodes ) : this._fragment.create();
nodes.forEach( @detachNode );
` :
deindent`
${options.dev && `if ( options.hydrate ) throw new Error( 'options.hydrate only works if the component was compiled with the \`hydratable: true\` option' );`}
this._fragment.create();
`}
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, options.anchor || null );
${props.map(prop => deindent`
get ${prop}() {
return this.get('${prop}');
}
set ${prop}(value) {
this.set({ ${prop}: value });
}
`).join('\n\n')}
${generator.slots.size && deindent`
connectedCallback() {
Object.keys(this._slotted).forEach(key => {
this.appendChild(this._slotted[key]);
});
}`}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
if ( !options._root ) {
${generator.hasComponents && `this._lock = true;`}
${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`}
${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`}
${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`}
${generator.hasComponents && `this._lock = false;`}
customElements.define('${generator.tag}', ${name});
@assign( ${prototypeBase}, ${proto}, {
_mount(target, anchor) {
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
`}
}
});
`);
} else {
builder.addBlock(deindent`
function ${name} ( options ) {
${constructorBody}
}
@assign( ${prototypeBase}, ${proto});
@assign( ${prototypeBase}, ${proto});
`);
}
// TODO deprecate component.teardown()
builder.addBlock(deindent`
${options.dev && deindent`
${name}.prototype._checkReadOnly = function _checkReadOnly ( newState ) {
${Array.from(generator.readonly).map(

@ -466,8 +466,7 @@ export default function preprocess(
const state: State = {
namespace,
parentNode: null,
parentNodes: 'nodes',
isTopLevel: true,
parentNodes: 'nodes'
};
generator.blocks.push(block);

@ -234,10 +234,10 @@ export default function visitComponent(
);
block.builders.mount.addLine(
`${name}._fragment.mount( ${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'} );`
`${name}._mount( ${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'} );`
);
if (!state.parentNode) block.builders.unmount.addLine(`${name}._fragment.unmount();`);
if (!state.parentNode) block.builders.unmount.addLine(`${name}._unmount();`);
block.builders.destroy.addLine(`${name}.destroy( false );`);

@ -8,6 +8,7 @@ import visitEventHandler from './EventHandler';
import visitBinding from './Binding';
import visitRef from './Ref';
import * as namespaces from '../../../../utils/namespaces';
import getStaticAttributeValue from '../../../shared/getStaticAttributeValue';
import addTransitions from './addTransitions';
import { DomGenerator } from '../../index';
import Block from '../../Block';
@ -45,7 +46,12 @@ export default function visitElement(
}
if (node.name === 'slot') {
return visitSlot(generator, block, state, node, elementStack, componentStack);
if (generator.customElement) {
const slotName = getStaticAttributeValue(node, 'name') || 'default';
generator.slots.add(slotName);
} else {
return visitSlot(generator, block, state, node, elementStack, componentStack);
}
}
if (generator.components.has(node.name) || node.name === ':Self') {
@ -88,7 +94,7 @@ export default function visitElement(
// add CSS encapsulation attribute
// TODO add a helper for this, rather than repeating it
if (node._needsCssAttribute) {
if (node._needsCssAttribute && !generator.customElement) {
generator.needsEncapsulateHelper = true;
block.builders.hydrate.addLine(
`@encapsulateStyles( ${name} );`

@ -94,7 +94,9 @@ export default function ssr(
visit(generator, mainBlock, node);
});
const { css, cssMap } = generator.stylesheet.render(options.filename);
const { css, cssMap } = generator.customElement ?
{ css: null, cssMap: null } :
generator.stylesheet.render(options.filename, true);
const result = deindent`
${hasJs && `[✂${parsed.js.content.start}-${parsed.js.content.end}✂]`}

@ -54,6 +54,7 @@ export interface CompileOptions {
cascade?: boolean;
hydratable?: boolean;
legacy?: boolean;
customElement: CustomElementOptions | true;
onerror?: (error: Error) => void;
onwarn?: (warning: Warning) => void;
@ -68,3 +69,8 @@ export interface Visitor {
enter: (node: Node) => void;
leave?: (node: Node) => void;
}
export interface CustomElementOptions {
tag?: string;
props?: string[];
}

@ -163,6 +163,14 @@ export function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
export function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
export function _unmount() {
this._fragment.unmount();
}
export var proto = {
destroy: destroy,
get: get,
@ -172,7 +180,9 @@ export var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
export var protoDev = {
@ -184,5 +194,7 @@ export var protoDev = {
set: set,
teardown: destroyDev,
_recompute: noop,
_set: _setDev
_set: _setDev,
_mount: _mount,
_unmount: _unmount
};

@ -9,6 +9,8 @@ import methods from './methods';
import components from './components';
import events from './events';
import namespace from './namespace';
import props from './props';
import tag from './tag';
import transitions from './transitions';
import setup from './setup';
@ -24,6 +26,8 @@ export default {
components,
events,
namespace,
props,
tag,
transitions,
setup,
};

@ -0,0 +1,20 @@
import { Validator } from '../../';
import { Node } from '../../../interfaces';
export default function props(validator: Validator, prop: Node) {
if (prop.value.type !== 'ArrayExpression') {
validator.error(
`'props' must be an array expression, if specified`,
prop.value.start
);
}
prop.value.elements.forEach((element: Node) => {
if (element.type !== 'Literal' || typeof element.value !== 'string') {
validator.error(
`'props' must be an array of string literals`,
element.start
);
}
});
}

@ -0,0 +1,19 @@
import { Validator } from '../../';
import { Node } from '../../../interfaces';
export default function tag(validator: Validator, prop: Node) {
if (prop.value.type !== 'Literal' || typeof prop.value.value !== 'string') {
validator.error(
`'tag' must be a string literal`,
prop.value.start
);
}
const tag = prop.value.value;
if (!/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
validator.error(
`tag name must be two or more words joined by the '-' character`,
prop.value.start
);
}
}

@ -153,6 +153,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -162,7 +170,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {

@ -129,6 +129,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -138,7 +146,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {

@ -149,6 +149,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -158,7 +166,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function encapsulateStyles ( node ) {

@ -0,0 +1,5 @@
export default {
options: {
customElement: true
}
};

@ -0,0 +1,262 @@
function noop() {}
function assign(target) {
var k,
source,
i = 1,
len = arguments.length;
for (; i < len; i++) {
source = arguments[i];
for (k in source) target[k] = source[k];
}
return target;
}
function appendNode(node, target) {
target.appendChild(node);
}
function insertNode(node, target, anchor) {
target.insertBefore(node, anchor);
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function createElement(name) {
return document.createElement(name);
}
function createText(data) {
return document.createTextNode(data);
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();
this._fragment = this._state = null;
}
function differs(a, b) {
return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function dispatchObservers(component, group, changed, newState, oldState) {
for (var key in group) {
if (!changed[key]) continue;
var newValue = newState[key];
var oldValue = oldState[key];
var callbacks = group[key];
if (!callbacks) continue;
for (var i = 0; i < callbacks.length; i += 1) {
var callback = callbacks[i];
if (callback.__calling) continue;
callback.__calling = true;
callback.call(component, newValue, oldValue);
callback.__calling = false;
}
}
}
function get(key) {
return key ? this._state[key] : this._state;
}
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
if (!handlers) return;
for (var i = 0; i < handlers.length; i += 1) {
handlers[i].call(this, data);
}
}
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
: this._observers.pre;
(group[key] || (group[key] = [])).push(callback);
if (!options || options.init !== false) {
callback.__calling = true;
callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
cancel: function() {
var index = group[key].indexOf(callback);
if (~index) group[key].splice(index, 1);
}
};
}
function on(eventName, handler) {
if (eventName === 'teardown') return this.on('destroy', handler);
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
handlers.push(handler);
return {
cancel: function() {
var index = handlers.indexOf(handler);
if (~index) handlers.splice(index, 1);
}
};
}
function set(newState) {
this._set(assign({}, newState));
if (this._root._lock) return;
this._root._lock = true;
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
this._root._lock = false;
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
for (var key in newState) {
if (differs(newState[key], oldState[key])) changed[key] = dirty = true;
}
if (!dirty) return;
this._state = assign({}, oldState, newState);
this._recompute(changed, this._state, oldState, false);
if (this._bind) this._bind(changed, this._state);
dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.update(changed, this._state);
dispatchObservers(this, this._observers.post, changed, this._state, oldState);
}
function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
fire: fire,
observe: observe,
on: on,
set: set,
teardown: destroy,
_recompute: noop,
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {
var h1, text, text_1, text_2;
return {
create: function () {
h1 = createElement( 'h1' );
text = createText( "Hello " );
text_1 = createText( state.name );
text_2 = createText( "!" );
},
mount: function ( target, anchor ) {
insertNode( h1, target, anchor );
appendNode( text, h1 );
appendNode( text_1, h1 );
appendNode( text_2, h1 );
},
update: function ( changed, state ) {
if ( changed.name ) {
text_1.data = state.name;
}
},
unmount: function () {
detachNode( h1 );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this.attachShadow({ mode: 'open' });
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return ["name"];
}
get name() {
return this.get('name');
}
set name(value) {
this.set({ name: value });
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,91 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) {
var h1, text, text_1, text_2;
return {
create: function () {
h1 = createElement( 'h1' );
text = createText( "Hello " );
text_1 = createText( state.name );
text_2 = createText( "!" );
},
mount: function ( target, anchor ) {
insertNode( h1, target, anchor );
appendNode( text, h1 );
appendNode( text_1, h1 );
appendNode( text_2, h1 );
},
update: function ( changed, state ) {
if ( changed.name ) {
text_1.data = state.name;
}
},
unmount: function () {
detachNode( h1 );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this.attachShadow({ mode: 'open' });
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return ["name"];
}
get name() {
return this.get('name');
}
set name(value) {
this.set({ name: value });
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,7 @@
<h1>Hello {{name}}!</h1>
<script>
export default {
tag: 'custom-element'
};
</script>

@ -0,0 +1,5 @@
export default {
options: {
customElement: true
}
};

@ -0,0 +1,278 @@
function noop() {}
function assign(target) {
var k,
source,
i = 1,
len = arguments.length;
for (; i < len; i++) {
source = arguments[i];
for (k in source) target[k] = source[k];
}
return target;
}
function appendNode(node, target) {
target.appendChild(node);
}
function insertNode(node, target, anchor) {
target.insertBefore(node, anchor);
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function createElement(name) {
return document.createElement(name);
}
function createText(data) {
return document.createTextNode(data);
}
function setAttribute(node, attribute, value) {
node.setAttribute(attribute, value);
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();
this._fragment = this._state = null;
}
function differs(a, b) {
return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function dispatchObservers(component, group, changed, newState, oldState) {
for (var key in group) {
if (!changed[key]) continue;
var newValue = newState[key];
var oldValue = oldState[key];
var callbacks = group[key];
if (!callbacks) continue;
for (var i = 0; i < callbacks.length; i += 1) {
var callback = callbacks[i];
if (callback.__calling) continue;
callback.__calling = true;
callback.call(component, newValue, oldValue);
callback.__calling = false;
}
}
}
function get(key) {
return key ? this._state[key] : this._state;
}
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
if (!handlers) return;
for (var i = 0; i < handlers.length; i += 1) {
handlers[i].call(this, data);
}
}
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
: this._observers.pre;
(group[key] || (group[key] = [])).push(callback);
if (!options || options.init !== false) {
callback.__calling = true;
callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
cancel: function() {
var index = group[key].indexOf(callback);
if (~index) group[key].splice(index, 1);
}
};
}
function on(eventName, handler) {
if (eventName === 'teardown') return this.on('destroy', handler);
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
handlers.push(handler);
return {
cancel: function() {
var index = handlers.indexOf(handler);
if (~index) handlers.splice(index, 1);
}
};
}
function set(newState) {
this._set(assign({}, newState));
if (this._root._lock) return;
this._root._lock = true;
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
this._root._lock = false;
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
for (var key in newState) {
if (differs(newState[key], oldState[key])) changed[key] = dirty = true;
}
if (!dirty) return;
this._state = assign({}, oldState, newState);
this._recompute(changed, this._state, oldState, false);
if (this._bind) this._bind(changed, this._state);
dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.update(changed, this._state);
dispatchObservers(this, this._observers.post, changed, this._state, oldState);
}
function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
fire: fire,
observe: observe,
on: on,
set: set,
teardown: destroy,
_recompute: noop,
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {
var div, slot, p, text, text_2, slot_1, p_1, text_3;
return {
create: function () {
div = createElement( 'div' );
slot = createElement( 'slot' );
p = createElement( 'p' );
text = createText( "default fallback content" );
text_2 = createText( "\n\n\t" );
slot_1 = createElement( 'slot' );
p_1 = createElement( 'p' );
text_3 = createText( "foo fallback content" );
this.hydrate();
},
hydrate: function ( nodes ) {
setAttribute( slot_1, 'name', "foo" );
},
mount: function ( target, anchor ) {
insertNode( div, target, anchor );
appendNode( slot, div );
appendNode( p, slot );
appendNode( text, p );
appendNode( text_2, div );
appendNode( slot_1, div );
appendNode( p_1, slot_1 );
appendNode( text_3, p_1 );
},
update: noop,
unmount: function () {
detachNode( div );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this._slotted = options.slots || {};
this.attachShadow({ mode: 'open' });
this.slots = {};
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return [];
}
connectedCallback() {
Object.keys(this._slotted).forEach(key => {
this.appendChild(this._slotted[key]);
});
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,103 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
function create_main_fragment ( state, component ) {
var div, slot, p, text, text_2, slot_1, p_1, text_3;
return {
create: function () {
div = createElement( 'div' );
slot = createElement( 'slot' );
p = createElement( 'p' );
text = createText( "default fallback content" );
text_2 = createText( "\n\n\t" );
slot_1 = createElement( 'slot' );
p_1 = createElement( 'p' );
text_3 = createText( "foo fallback content" );
this.hydrate();
},
hydrate: function ( nodes ) {
setAttribute( slot_1, 'name', "foo" );
},
mount: function ( target, anchor ) {
insertNode( div, target, anchor );
appendNode( slot, div );
appendNode( p, slot );
appendNode( text, p );
appendNode( text_2, div );
appendNode( slot_1, div );
appendNode( p_1, slot_1 );
appendNode( text_3, p_1 );
},
update: noop,
unmount: function () {
detachNode( div );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this._slotted = options.slots || {};
this.attachShadow({ mode: 'open' });
this.slots = {};
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return [];
}
connectedCallback() {
Object.keys(this._slotted).forEach(key => {
this.appendChild(this._slotted[key]);
});
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,15 @@
<div>
<slot>
<p>default fallback content</p>
</slot>
<slot name='foo'>
<p>foo fallback content</p>
</slot>
</div>
<script>
export default {
tag: 'custom-element'
};
</script>

@ -0,0 +1,5 @@
export default {
options: {
customElement: true
}
};

@ -0,0 +1,263 @@
function noop() {}
function assign(target) {
var k,
source,
i = 1,
len = arguments.length;
for (; i < len; i++) {
source = arguments[i];
for (k in source) target[k] = source[k];
}
return target;
}
function appendNode(node, target) {
target.appendChild(node);
}
function insertNode(node, target, anchor) {
target.insertBefore(node, anchor);
}
function detachNode(node) {
node.parentNode.removeChild(node);
}
function createElement(name) {
return document.createElement(name);
}
function createText(data) {
return document.createTextNode(data);
}
function destroy(detach) {
this.destroy = noop;
this.fire('destroy');
this.set = this.get = noop;
if (detach !== false) this._fragment.unmount();
this._fragment.destroy();
this._fragment = this._state = null;
}
function differs(a, b) {
return a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function dispatchObservers(component, group, changed, newState, oldState) {
for (var key in group) {
if (!changed[key]) continue;
var newValue = newState[key];
var oldValue = oldState[key];
var callbacks = group[key];
if (!callbacks) continue;
for (var i = 0; i < callbacks.length; i += 1) {
var callback = callbacks[i];
if (callback.__calling) continue;
callback.__calling = true;
callback.call(component, newValue, oldValue);
callback.__calling = false;
}
}
}
function get(key) {
return key ? this._state[key] : this._state;
}
function fire(eventName, data) {
var handlers =
eventName in this._handlers && this._handlers[eventName].slice();
if (!handlers) return;
for (var i = 0; i < handlers.length; i += 1) {
handlers[i].call(this, data);
}
}
function observe(key, callback, options) {
var group = options && options.defer
? this._observers.post
: this._observers.pre;
(group[key] || (group[key] = [])).push(callback);
if (!options || options.init !== false) {
callback.__calling = true;
callback.call(this, this._state[key]);
callback.__calling = false;
}
return {
cancel: function() {
var index = group[key].indexOf(callback);
if (~index) group[key].splice(index, 1);
}
};
}
function on(eventName, handler) {
if (eventName === 'teardown') return this.on('destroy', handler);
var handlers = this._handlers[eventName] || (this._handlers[eventName] = []);
handlers.push(handler);
return {
cancel: function() {
var index = handlers.indexOf(handler);
if (~index) handlers.splice(index, 1);
}
};
}
function set(newState) {
this._set(assign({}, newState));
if (this._root._lock) return;
this._root._lock = true;
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
this._root._lock = false;
}
function _set(newState) {
var oldState = this._state,
changed = {},
dirty = false;
for (var key in newState) {
if (differs(newState[key], oldState[key])) changed[key] = dirty = true;
}
if (!dirty) return;
this._state = assign({}, oldState, newState);
this._recompute(changed, this._state, oldState, false);
if (this._bind) this._bind(changed, this._state);
dispatchObservers(this, this._observers.pre, changed, this._state, oldState);
this._fragment.update(changed, this._state);
dispatchObservers(this, this._observers.post, changed, this._state, oldState);
}
function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
fire: fire,
observe: observe,
on: on,
set: set,
teardown: destroy,
_recompute: noop,
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {
var h1, text, text_1, text_2;
return {
create: function () {
h1 = createElement( 'h1' );
text = createText( "Hello " );
text_1 = createText( state.name );
text_2 = createText( "!" );
},
mount: function ( target, anchor ) {
insertNode( h1, target, anchor );
appendNode( text, h1 );
appendNode( text_1, h1 );
appendNode( text_2, h1 );
},
update: function ( changed, state ) {
if ( changed.name ) {
text_1.data = state.name;
}
},
unmount: function () {
detachNode( h1 );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`;
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return ["name"];
}
get name() {
return this.get('name');
}
set name(value) {
this.set({ name: value });
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,92 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) {
var h1, text, text_1, text_2;
return {
create: function () {
h1 = createElement( 'h1' );
text = createText( "Hello " );
text_1 = createText( state.name );
text_2 = createText( "!" );
},
mount: function ( target, anchor ) {
insertNode( h1, target, anchor );
appendNode( text, h1 );
appendNode( text_1, h1 );
appendNode( text_2, h1 );
},
update: function ( changed, state ) {
if ( changed.name ) {
text_1.data = state.name;
}
},
unmount: function () {
detachNode( h1 );
},
destroy: noop
};
}
class SvelteComponent extends HTMLElement {
constructor(options = {}) {
super();
this.options = options;
this._state = options.data || {};
this._observers = {
pre: Object.create( null ),
post: Object.create( null )
};
this._handlers = Object.create( null );
this._root = options._root || this;
this._yield = options._yield;
this._bind = options._bind;
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`;
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
this._mount( options.target, options.anchor || null );
}
}
static get observedAttributes() {
return ["name"];
}
get name() {
return this.get('name');
}
set name(value) {
this.set({ name: value });
}
attributeChangedCallback ( attr, oldValue, newValue ) {
this.set({ [attr]: newValue });
}
}
customElements.define('custom-element', SvelteComponent);
assign( SvelteComponent.prototype, proto , {
_mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor);
},
_unmount() {
this.parentNode.removeChild(this);
}
});
export default SvelteComponent;

@ -0,0 +1,13 @@
<h1>Hello {{name}}!</h1>
<style>
h1 {
color: red;
}
</style>
<script>
export default {
tag: 'custom-element'
};
</script>

@ -162,6 +162,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -171,7 +179,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -149,6 +149,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -158,7 +166,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {

@ -153,6 +153,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -162,7 +170,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -153,6 +153,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -162,7 +170,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -145,6 +145,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -154,7 +162,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -145,6 +145,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -154,7 +162,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -145,6 +145,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -154,7 +162,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -145,6 +145,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -154,7 +162,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -147,6 +147,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -156,7 +164,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -143,6 +143,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -152,7 +160,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {
@ -182,17 +192,17 @@ function create_main_fragment ( state, component ) {
},
mount: function ( target, anchor ) {
imported._fragment.mount( target, anchor );
imported._mount( target, anchor );
insertNode( text, target, anchor );
nonimported._fragment.mount( target, anchor );
nonimported._mount( target, anchor );
},
update: noop,
unmount: function () {
imported._fragment.unmount();
imported._unmount();
detachNode( text );
nonimported._fragment.unmount();
nonimported._unmount();
},
destroy: function () {
@ -228,9 +238,7 @@ function SvelteComponent ( options ) {
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, options.anchor || null );
}
if ( !options._root ) {
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);

@ -29,17 +29,17 @@ function create_main_fragment ( state, component ) {
},
mount: function ( target, anchor ) {
imported._fragment.mount( target, anchor );
imported._mount( target, anchor );
insertNode( text, target, anchor );
nonimported._fragment.mount( target, anchor );
nonimported._mount( target, anchor );
},
update: noop,
unmount: function () {
imported._fragment.unmount();
imported._unmount();
detachNode( text );
nonimported._fragment.unmount();
nonimported._unmount();
},
destroy: function () {
@ -75,9 +75,7 @@ function SvelteComponent ( options ) {
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, options.anchor || null );
}
if ( !options._root ) {
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);

@ -129,6 +129,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -138,7 +146,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {
@ -193,9 +203,7 @@ function SvelteComponent ( options ) {
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, options.anchor || null );
}
if ( !options._root ) {
callAll(this._oncreate);
}
}

@ -52,9 +52,7 @@ function SvelteComponent ( options ) {
if ( options.target ) {
this._fragment.create();
this._fragment.mount( options.target, options.anchor || null );
}
if ( !options._root ) {
callAll(this._oncreate);
}
}

@ -129,6 +129,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -138,7 +146,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
var template = (function () {

@ -153,6 +153,14 @@ function callAll(fns) {
while (fns && fns.length) fns.pop()();
}
function _mount(target, anchor) {
this._fragment.mount(target, anchor);
}
function _unmount() {
this._fragment.unmount();
}
var proto = {
destroy: destroy,
get: get,
@ -162,7 +170,9 @@ var proto = {
set: set,
teardown: destroy,
_recompute: noop,
_set: _set
_set: _set,
_mount: _mount,
_unmount: _unmount
};
function create_main_fragment ( state, component ) {

@ -22,8 +22,6 @@ function getName(filename) {
return base[0].toUpperCase() + base.slice(1);
}
const Object_assign = Object.assign;
describe("runtime", () => {
before(() => {
svelte = loadSvelte(true);

Loading…
Cancel
Save