This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

34
node_modules/@riotjs/hot-reload/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import {__, component} from 'riot'
import $ from 'bianco.query'
const { cssManager } = __
const { DOM_COMPONENT_INSTANCE_PROPERTY } = __.globals
export function reload(componentAPI) {
const {name} = componentAPI
if (!name) {
console.warn('Anonymous components can not be reloaded') // eslint-disable-line
return []
}
return $(`${name}, [is=${name}]`).map(el => {
const oldTag = el[DOM_COMPONENT_INSTANCE_PROPERTY]
// early return in case there is no riot instance found
if (!oldTag) return
// remove the tag template from the DOM
oldTag.unmount(true)
// delete the old css from the css manager
cssManager.remove(name)
// create the new tag
const newTag = component(componentAPI)(el, oldTag.props)
newTag.update(oldTag.state)
return newTag
})
}
export default reload