html-element-extended
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -68,2 +68,5 @@ /* Summary | ||
// For now using yaml imported by caller | ||
// import yaml from "js-yaml"; | ||
async function GETp(httpurl, opts) { | ||
@@ -94,2 +97,4 @@ /** | ||
throw new Error(`${httpurl} ${response.status}: ${response.statusText}`); | ||
} else if (response.headers.get('Content-Type').startsWith('text/yaml')) { | ||
return response.body; // Let caller handle it | ||
} else if (!response.headers.get('Content-Type').startsWith('application/json')) { | ||
@@ -114,4 +119,9 @@ throw new Error(`Query for ${httpurl} Did not return JSON`); | ||
// The "" may or may not be correct, when used as a webcomponent <foo-bar discover> will pass a value of "", unclear if there is any existing example where empty string is presumed false | ||
return ["true", "TRUE", 1, "1", true, ""].includes(value); | ||
return ["true", "TRUE", 1, "1", "1.0", true, ""].includes(value); | ||
} | ||
// Used to apply different rules to boolean properties | ||
// Note form.autocomplete is text "on" or "off" translate is yes/no | ||
booleanAttributes = ['autofocus','autoplay','checked','contenteditable','controls','default', | ||
'defer','disabled','draggable','hidden','indeterminate','inert','loop','multiple','muted', | ||
'novalidate','open','readonly','required','selected','spellcheck'] | ||
// Standardish routing to allow nesting Elements inside JS | ||
@@ -130,3 +140,3 @@ function EL(tag, attributes = {}, children) { | ||
el[kv[0]] = kv[1]; | ||
} else if (['checked', 'indeterminate', 'selected'].includes(kv[0])) { //TODO this should be generic | ||
} else if (booleanAttributes.includes(`${tag}.${kv[0]})) { | ||
el[kv[0]] = toBool(kv[1]); // Booleans are set as fields of the element | ||
@@ -263,2 +273,3 @@ } else if ((typeof kv[1] === 'object') && (kv[1] !== null)) { | ||
// renderAndReplace should test if it wants to render an empty element if there is no data | ||
// Note that some users of this library are prefering a connectedCallback that doesn't renderAndReplace and uses 'slot' etc | ||
this.renderAndReplace(); | ||
@@ -265,0 +276,0 @@ } |
@@ -29,3 +29,3 @@ { | ||
"type": "module", | ||
"version": "0.1.2" | ||
"version": "0.1.3" | ||
} |
58277
352