@ -4,6 +4,7 @@ import {
child ,
child ,
clone _node ,
clone _node ,
create _element ,
create _element ,
empty ,
init _operations ,
init _operations ,
map _get ,
map _get ,
map _set ,
map _set ,
@ -75,11 +76,6 @@ const all_registerd_events = new Set();
/** @type {Set<(events: Array<string>) => void>} */
/** @type {Set<(events: Array<string>) => void>} */
const root _event _handles = new Set ( ) ;
const root _event _handles = new Set ( ) ;
/** @returns {Text} */
export function empty ( ) {
return document . createTextNode ( '' ) ;
}
/ * *
/ * *
* @ param { string } html
* @ param { string } html
* @ param { boolean } return _fragment
* @ param { boolean } return _fragment
@ -212,11 +208,22 @@ const space_template = template(' ', false);
const comment _template = template ( '<!>' , true ) ;
const comment _template = template ( '<!>' , true ) ;
/ * *
/ * *
* @ param { null | Text | Comment | Element } anchor
* @ param { Text | Comment | Element | null } anchor
* /
* /
/*#__NO_SIDE_EFFECTS__*/
/*#__NO_SIDE_EFFECTS__*/
export function space ( anchor ) {
export function space ( anchor ) {
return open ( anchor , true , space _template ) ;
/** @type {Node | null} */
var node = /** @type {any} */ ( open ( anchor , true , space _template ) ) ;
// if an {expression} is empty during SSR, there might be no
// text node to hydrate (or an anchor comment is falsely detected instead)
// — we must therefore create one
if ( current _hydration _fragment !== null && node ? . nodeType !== 3 ) {
node = empty ( ) ;
// @ts-ignore in this case the anchor should always be a comment,
// if not something more fundamental is wrong and throwing here is better to bail out early
anchor . parentElement . insertBefore ( node , anchor ) ;
}
return node ;
}
}
/ * *
/ * *
@ -228,6 +235,8 @@ export function comment(anchor) {
}
}
/ * *
/ * *
* Assign the created ( or in hydration mode , traversed ) dom elements to the current block
* and insert the elements into the dom ( in client mode ) .
* @ param { Element | Text } dom
* @ param { Element | Text } dom
* @ param { boolean } is _fragment
* @ param { boolean } is _fragment
* @ param { null | Text | Comment | Element } anchor
* @ param { null | Text | Comment | Element } anchor
@ -2866,7 +2875,9 @@ export function mount(component, options) {
const container = options . target ;
const container = options . target ;
const block = create _root _block ( options . intro || false ) ;
const block = create _root _block ( options . intro || false ) ;
const first _child = /** @type {ChildNode} */ ( container . firstChild ) ;
const first _child = /** @type {ChildNode} */ ( container . firstChild ) ;
const hydration _fragment = get _hydration _fragment ( first _child ) ;
// Call with insert_text == true to prevent empty {expressions} resulting in an empty
// fragment array, resulting in a hydration error down the line
const hydration _fragment = get _hydration _fragment ( first _child , true ) ;
const previous _hydration _fragment = current _hydration _fragment ;
const previous _hydration _fragment = current _hydration _fragment ;
/** @type {Exports} */
/** @type {Exports} */