@riotjs/util
Advanced tools
Comparing version 0.0.0 to 1.0.0
@@ -12,2 +12,22 @@ /** | ||
/** | ||
* Check if an element is part of an svg | ||
* @param {HTMLElement} el - element to check | ||
* @returns {boolean} true if we are in an svg context | ||
*/ | ||
export function isSvg(el) { | ||
const owner = el.ownerSVGElement | ||
return !!owner || owner === null | ||
} | ||
/** | ||
* Check if an element is a template tag | ||
* @param {HTMLElement} el - element to check | ||
* @returns {boolean} true if it's a <template> | ||
*/ | ||
export function isTemplate(el) { | ||
return !isNil(el.content) | ||
} | ||
/** | ||
* Check that will be passed if its argument is a function | ||
@@ -14,0 +34,0 @@ * @param {*} value - value to check |
33
dom.js
@@ -14,1 +14,34 @@ import {dashToCamelCase} from './strings' | ||
} | ||
/** | ||
* Move all the child nodes from a source tag to another | ||
* @param {HTMLElement} source - source node | ||
* @param {HTMLElement} target - target node | ||
* @returns {undefined} it's a void method ¯\_(ツ)_/¯ | ||
*/ | ||
// Ignore this helper because it's needed only for svg tags | ||
export function moveChildren(source, target) { | ||
if (source.firstChild) { | ||
target.appendChild(source.firstChild) | ||
moveChildren(source, target) | ||
} | ||
} | ||
/** | ||
* Remove the child nodes from any DOM node | ||
* @param {HTMLElement} node - target node | ||
* @returns {undefined} | ||
*/ | ||
export function cleanNode(node) { | ||
clearChildren(node.childNodes) | ||
} | ||
/** | ||
* Clear multiple children in a node | ||
* @param {HTMLElement[]} children - direct children nodes | ||
* @returns {undefined} | ||
*/ | ||
export function clearChildren(children) { | ||
Array.from(children).forEach(n => n.parentNode && n.parentNode.removeChild(n)) | ||
} |
{ | ||
"name": "@riotjs/util", | ||
"version": "0.0.0", | ||
"version": "1.0.0", | ||
"description": "Riot.js util functions", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11247
254
1