@webtides/element-js 1.0.0-alpha.10 → 1.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtides/element-js",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.11",
4
4
  "module": "index.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,12 @@ export { toString } from './util/toString.js';
24
24
 
25
25
  /**
26
26
  * Options object for the BaseElement propertyOptions option
27
- * @typedef {Object} PropertyOptions
27
+ * @typedef {Object<string, PropertyOption>} PropertyOptions
28
+ */
29
+
30
+ /**
31
+ * Option object for a property of the BaseElement propertyOptions option
32
+ * @typedef {Object} PropertyOption
28
33
  * @property {undefined | boolean | function} [reflect] - When set to true the element will reflect property changes back to attributes if the attribute was not present when connecting the element. By default, all attributes that are present when connecting the element will be reflected anyway. Default is `undefined`
29
34
  * @property {undefined | boolean | function} [parse] - When set to false the element will not automatically try to parse the attributes string value to a complex type (number, array, object). Default is `undefined`
30
35
  * @property {undefined | boolean | function} [notify] - When set to true the element will dispatch CustomEvents for every property/attribute change. The event name will be the property name all lowercase and camel to dashes with a postfix of -changed. Default is `undefined`
@@ -37,7 +37,7 @@ class TemplateElement extends StyledElement {
37
37
 
38
38
  /**
39
39
  * The template method should be overridden in extending elements and return the template to be rendered to the root
40
- * @returns {TemplateResult}
40
+ * @returns {TemplateResult | string}
41
41
  */
42
42
  template() {
43
43
  return html``;
@@ -57,12 +57,7 @@ class TemplateElement extends StyledElement {
57
57
  */
58
58
  renderTemplate() {
59
59
  const template = this._template || this.template();
60
- if (typeof template === 'string') {
61
- // just a plain string literal. no lit-html required
62
- this.getRoot().innerHTML = `${template}`;
63
- } else {
64
- render(template, this.getRoot());
65
- }
60
+ render(template, this.getRoot());
66
61
  }
67
62
 
68
63
  /**
@@ -4,7 +4,12 @@
4
4
  * @param {Element} domNode
5
5
  */
6
6
  const render = (template, domNode) => {
7
- template.renderInto(domNode);
7
+ if (typeof template === 'string') {
8
+ // just a plain string (or literal)
9
+ domNode.innerHTML = template;
10
+ } else {
11
+ template.renderInto(domNode);
12
+ }
8
13
  };
9
14
 
10
15
  export { render };