0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 01:11:24 +01:00
svelte/test/js/samples/css-media-query/expected.js

68 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-08-14 04:36:39 +02:00
import { appendNode, assign, createElement, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
2017-07-25 00:36:22 +02:00
function encapsulateStyles ( node ) {
setAttribute( node, 'svelte-2363328337', '' );
}
2017-07-25 00:36:22 +02:00
function add_css () {
var style = createElement( 'style' );
style.id = 'svelte-2363328337-style';
style.textContent = "@media(min-width: 1px){div[svelte-2363328337],[svelte-2363328337] div{color:red}}";
2017-07-25 00:36:22 +02:00
appendNode( style, document.head );
}
function create_main_fragment ( state, component ) {
var div;
return {
create: function () {
div = createElement( 'div' );
this.hydrate();
},
hydrate: function ( nodes ) {
encapsulateStyles( div );
2017-07-25 00:36:22 +02:00
},
mount: function ( target, anchor ) {
insertNode( div, target, anchor );
},
2017-08-14 04:36:39 +02:00
update: noop,
2017-07-25 00:36:22 +02:00
unmount: function () {
detachNode( div );
},
destroy: noop
};
}
function SvelteComponent ( options ) {
2017-08-29 14:43:11 +02:00
this.options = options;
2017-07-25 00:36:22 +02:00
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;
2017-08-15 21:15:22 +02:00
this._bind = options._bind;
2017-07-25 00:36:22 +02:00
if ( !document.getElementById( 'svelte-2363328337-style' ) ) add_css();
this._fragment = create_main_fragment( this._state, this );
if ( options.target ) {
this._fragment.create();
2017-08-25 19:24:08 +02:00
this._fragment.mount( options.target, options.anchor || null );
2017-07-25 00:36:22 +02:00
}
}
assign( SvelteComponent.prototype, proto );
export default SvelteComponent;