@jeefo/jqlite
Advanced tools
Comparing version 0.0.1 to 0.0.2
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : event_methods.js | ||
* Created at : 2017-08-03 | ||
* Updated at : 2019-10-11 | ||
* Updated at : 2019-11-16 | ||
* Author : jeefo | ||
@@ -109,5 +109,8 @@ * Purpose : | ||
const event = new Event(event_name, options); | ||
return this.DOM_element.dispatchEvent(event); | ||
if (this.DOM_element) { | ||
return this.DOM_element.dispatchEvent(event); | ||
} | ||
return true; | ||
}); | ||
}; |
24
index.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : index.js | ||
* Created at : 2017-08-08 | ||
* Updated at : 2019-06-27 | ||
* Updated at : 2019-11-17 | ||
* Author : jeefo | ||
@@ -20,2 +20,4 @@ * Purpose : | ||
const is_object = o => o !== null && typeof o === "object"; | ||
module.exports = function jqlite (element) { | ||
@@ -29,14 +31,16 @@ if (JeefoElement.is_jeefo_element(element)) { | ||
if (wrapper.childNodes.length > 1) { | ||
throw new Error("JeefoElement must be exactly 1 DOM Element"); | ||
const elements = []; | ||
while (wrapper.firstChild) { | ||
elements.push(wrapper.firstChild); | ||
wrapper.removeChild(wrapper.firstChild); | ||
} | ||
element = wrapper.childNodes[0]; | ||
wrapper.innerHTML = ''; | ||
if (elements.length > 1) { | ||
return new JeefoElements(elements); | ||
} else if (elements.length === 1) { | ||
element = elements[0]; | ||
} | ||
} | ||
if (element !== null && typeof element === "object") { | ||
if ("nodeType" in element) { | ||
return new JeefoElement(element); | ||
} | ||
return new JeefoElements(element); | ||
if (is_object(element) && "nodeType" in element) { | ||
return new JeefoElement(element); | ||
} | ||
@@ -43,0 +47,0 @@ |
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : jeefo_element.js | ||
* Created at : 2017-01-06 | ||
* Updated at : 2019-10-17 | ||
* Updated at : 2019-11-16 | ||
* Author : jeefo | ||
@@ -105,9 +105,2 @@ * Purpose : | ||
// DOM methods | ||
remove () { | ||
this.trigger("ditach"); | ||
if (this.DOM_element.parentNode) { | ||
this.DOM_element.parentNode.removeChild(this.DOM_element); | ||
} | ||
} | ||
get value () { | ||
@@ -144,18 +137,10 @@ switch (this.DOM_element.tagName) { | ||
replace (node) { | ||
if (node.type === JEEFO_ELEMENT) { | ||
node.trigger("detach"); | ||
node = node.DOM_element; | ||
} else { | ||
const $node = new JeefoElement(node); | ||
$node.trigger("detach"); | ||
// DOM methods | ||
remove () { | ||
this.trigger("ditach"); | ||
if (this.DOM_element && this.DOM_element.parentNode) { | ||
this.DOM_element.parentNode.removeChild(this.DOM_element); | ||
} | ||
this.DOM_element.parentNode.replaceChild(node, this.DOM_element); | ||
this.DOM_element = node; | ||
return this; | ||
this.DOM_element = null; | ||
} | ||
append (node) { | ||
if (node.type === JEEFO_ELEMENT) { node = node.DOM_element; } | ||
this.DOM_element.appendChild(node); | ||
} | ||
before (node) { | ||
@@ -174,2 +159,18 @@ if (node.type === JEEFO_ELEMENT) { node = node.DOM_element; } | ||
} | ||
append (node) { | ||
if (node.type === JEEFO_ELEMENT) { node = node.DOM_element; } | ||
this.DOM_element.appendChild(node); | ||
} | ||
replace (node) { | ||
if (node.type === JEEFO_ELEMENT) { | ||
node.trigger("detach"); | ||
node = node.DOM_element; | ||
} else { | ||
const $node = new JeefoElement(node); | ||
$node.trigger("detach"); | ||
} | ||
this.DOM_element.parentNode.replaceChild(node, this.DOM_element); | ||
this.DOM_element = node; | ||
return this; | ||
} | ||
@@ -191,2 +192,5 @@ // Selector methods | ||
} | ||
prev () { | ||
return new JeefoElement(this.DOM_element.previousSibling); | ||
} | ||
next () { | ||
@@ -193,0 +197,0 @@ return new JeefoElement(this.DOM_element.nextElementSibling); |
{ | ||
"name": "@jeefo/jqlite", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/je3f0o/jeefo_jqlite", | ||
"copyright": "2018", | ||
"description": "Very lite version of jquery for jeefo framework.", | ||
"description": "Very simple DOM wrapper library for jeefo framework.", | ||
"author": { | ||
@@ -13,2 +13,4 @@ "name": "je3f0o", | ||
"scripts": { | ||
"save": "git add . && git c \"`date`\" && git p", | ||
"save_version": "git add . && git c \"v$npm_package_version\" && git p", | ||
"jeefo_publish": "node node_modules/@jeefo/publish/publish.js" | ||
@@ -15,0 +17,0 @@ }, |
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
21722
625