$
This commit is contained in:
22
node_modules/riot/esm/api/unmount.js
generated
vendored
Normal file
22
node_modules/riot/esm/api/unmount.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Riot WIP, @license MIT */
|
||||
import $ from 'bianco.query';
|
||||
import { DOM_COMPONENT_INSTANCE_PROPERTY } from '@riotjs/util';
|
||||
|
||||
/**
|
||||
* Sweet unmounting helper function for the DOM node mounted manually by the user
|
||||
* @param {string|HTMLElement} selector - query for the selection or a DOM element
|
||||
* @param {boolean|null} keepRootElement - if true keep the root element
|
||||
* @returns {Array} list of nodes unmounted
|
||||
*/
|
||||
|
||||
function unmount(selector, keepRootElement) {
|
||||
return $(selector).map(element => {
|
||||
if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
|
||||
element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
|
||||
}
|
||||
|
||||
return element;
|
||||
});
|
||||
}
|
||||
|
||||
export { unmount };
|
Reference in New Issue
Block a user