Comparing version 1.2.9 to 1.2.10
# Changelog | ||
## 1.2.9- 2021-01-25 | ||
- Add new function `setShouldSetReactivity` | ||
## 1.2.9- 2021-01-24 | ||
@@ -4,0 +8,0 @@ |
@@ -27,2 +27,3 @@ // Safari Polyfills | ||
let insertBeforeDiffing = false; | ||
let shouldSetReactivity = true; | ||
let isScheduling = false; // Helper - checks if code is already in requestIdleCallback | ||
@@ -97,2 +98,5 @@ const reactivityRegex = /\{\{((\s|.)*?)\}\}/; | ||
} | ||
function setShouldSetReactivity(willSet) { | ||
shouldSetReactivity = willSet; | ||
} | ||
function setHydroRecursive(obj, willSchedule) { | ||
@@ -190,6 +194,8 @@ Reflect.set(obj, "asyncUpdate" /* asyncUpdate */, willSchedule); | ||
DOM.querySelectorAll("template[id^=lbInsertNodes]").forEach((template) => template.replaceWith(insertNodes.shift())); | ||
setReactivity(DOM, eventFunctions); | ||
if (shouldSetReactivity) | ||
setReactivity(DOM, eventFunctions); | ||
// Set reactive Behavior if only a Text Node is present | ||
if (DOM.childElementCount === 0 && DOM.firstChild) { | ||
setReactivitySingle(DOM.firstChild); | ||
if (shouldSetReactivity) | ||
setReactivitySingle(DOM.firstChild); | ||
// Return Text Node | ||
@@ -1212,2 +1218,2 @@ return DOM.firstChild; | ||
}; | ||
module.exports = { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; | ||
module.exports = { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, setShouldSetReactivity, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; |
@@ -41,2 +41,3 @@ declare global { | ||
declare function setInsertDiffing(willInsert: boolean): void; | ||
declare function setShouldSetReactivity(willSet: boolean): void; | ||
declare function html(htmlArray: TemplateStringsArray, // The Input String, which is splitted by the template variables | ||
@@ -72,2 +73,2 @@ ...variables: Array<any>): Element | DocumentFragment | Text; | ||
}; | ||
export { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; | ||
export { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, setShouldSetReactivity, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; |
@@ -27,2 +27,3 @@ // Safari Polyfills | ||
let insertBeforeDiffing = false; | ||
let shouldSetReactivity = true; | ||
let isScheduling = false; // Helper - checks if code is already in requestIdleCallback | ||
@@ -97,2 +98,5 @@ const reactivityRegex = /\{\{((\s|.)*?)\}\}/; | ||
} | ||
function setShouldSetReactivity(willSet) { | ||
shouldSetReactivity = willSet; | ||
} | ||
function setHydroRecursive(obj, willSchedule) { | ||
@@ -190,6 +194,8 @@ Reflect.set(obj, "asyncUpdate" /* asyncUpdate */, willSchedule); | ||
DOM.querySelectorAll("template[id^=lbInsertNodes]").forEach((template) => template.replaceWith(insertNodes.shift())); | ||
setReactivity(DOM, eventFunctions); | ||
if (shouldSetReactivity) | ||
setReactivity(DOM, eventFunctions); | ||
// Set reactive Behavior if only a Text Node is present | ||
if (DOM.childElementCount === 0 && DOM.firstChild) { | ||
setReactivitySingle(DOM.firstChild); | ||
if (shouldSetReactivity) | ||
setReactivitySingle(DOM.firstChild); | ||
// Return Text Node | ||
@@ -1212,2 +1218,2 @@ return DOM.firstChild; | ||
}; | ||
export { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; | ||
export { render, html, hydro, setGlobalSchedule, setReuseElements, setInsertDiffing, setShouldSetReactivity, reactive, unset, setAsyncUpdate, unobserve, observe, ternary, emit, watchEffect, internals, getValue, onRender, onCleanup, setReactivity, $, $$, }; |
{ | ||
"name": "hydro-js", | ||
"version": "1.2.9", | ||
"version": "1.2.10", | ||
"description": "A lightweight reactive library", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -108,2 +108,3 @@ declare const window: any; | ||
let insertBeforeDiffing = false; | ||
let shouldSetReactivity = true; | ||
let isScheduling = false; // Helper - checks if code is already in requestIdleCallback | ||
@@ -184,2 +185,5 @@ | ||
} | ||
function setShouldSetReactivity(willSet: boolean): void { | ||
shouldSetReactivity = willSet; | ||
} | ||
function setHydroRecursive(obj: hydroObject, willSchedule: boolean) { | ||
@@ -305,7 +309,7 @@ Reflect.set(obj, Placeholder.asyncUpdate, willSchedule); | ||
setReactivity(DOM, eventFunctions); | ||
if (shouldSetReactivity) setReactivity(DOM, eventFunctions); | ||
// Set reactive Behavior if only a Text Node is present | ||
if (DOM.childElementCount === 0 && DOM.firstChild) { | ||
setReactivitySingle(DOM.firstChild as Text); | ||
if (shouldSetReactivity) setReactivitySingle(DOM.firstChild as Text); | ||
// Return Text Node | ||
@@ -1526,2 +1530,3 @@ return DOM.firstChild as Text; | ||
setInsertDiffing, | ||
setShouldSetReactivity, | ||
reactive, | ||
@@ -1528,0 +1533,0 @@ unset, |
301631
5805