Skip to content

Commit 9baa346

Browse files
committed
add option allowLiveBinding to avoid (caught) exceptions, on systems
that support live bindings
1 parent ac3373e commit 9baa346

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/make-hot.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ const defaultHotOptions = {
4040

4141
// disable runtime error overlay
4242
noOverlay: false,
43+
44+
// set to true on systems that supports them, to avoid useless caught /
45+
// managed (but still...) exceptions, by using Svelte's current_component
46+
// instead of get_current_component
47+
allowLiveBinding: false,
4348
}
4449

4550
const defaultHotApi = 'hot-api-esm.js'

runtime/proxy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class ProxyComponent {
237237
try {
238238
let lastProperties
239239
const _cmp = createProxiedComponent(current.Component, options, {
240+
allowLiveBinding: current.hotOptions.allowLiveBinding,
240241
onDestroy,
241242
onMount: afterMount,
242243
onInstance: comp => {

runtime/svelte-hooks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const get_current_component_safe = () => {
8484
export const createProxiedComponent = (
8585
Component,
8686
initialOptions,
87-
{ onInstance, onMount, onDestroy }
87+
{ allowLiveBinding, onInstance, onMount, onDestroy }
8888
) => {
8989
let cmp
9090
let options = initialOptions
@@ -255,7 +255,9 @@ export const createProxiedComponent = (
255255
}
256256
}
257257

258-
const parentComponent = get_current_component_safe()
258+
const parentComponent = allowLiveBinding
259+
? current_component
260+
: get_current_component_safe()
259261

260262
cmp = new Component(options)
261263
cmp.$$.hmr_cmp = cmp

0 commit comments

Comments
 (0)