Skip to content

Commit

Permalink
Crel: Check for invalid element
Browse files Browse the repository at this point in the history
  • Loading branch information
fluvf committed Mar 5, 2019
1 parent 1806e47 commit 3983985
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ This might make it harder to read at times, but the code's intention should be t
},
// Define our function as a proxy interface
crel = new Proxy((element, ...children) => {
// If first argument is an element, use it as is, otherwise treat it as a tagname
if (!crel.isElement(element)) {
if (!isType(element, 'string') || element.length < 1) {
return; // Do nothing on invalid input
}
element = d.createElement(element);
}
// Define all used variables / shortcuts here, to make things smaller once compiled
let settings = children[0],
key,
attribute;
// If first argument is an element, use it as is, otherwise treat it as a tagname
element = crel.isElement(element) ? element : d.createElement(element);
// Check if second argument is a settings object
if (isType(settings, 'object') && !crel[isNodeString](settings) && !Array.isArray(settings)) {
// Don't treat settings as a child
Expand Down

0 comments on commit 3983985

Please sign in to comment.