veles 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
@@ -168,6 +168,39 @@ function parseChildren({ children, htmlElement, velesNode, portal }) {
168
168
  return childComponents;
169
169
  }
170
170
  //#endregion
171
+ //#region src/attribute-utils.ts
172
+ const ENUMERATED_BOOLEAN_ATTRIBUTES = {
173
+ draggable: {
174
+ trueValue: "true",
175
+ falseValue: "false"
176
+ },
177
+ contenteditable: {
178
+ trueValue: "true",
179
+ falseValue: "false"
180
+ },
181
+ spellcheck: {
182
+ trueValue: "true",
183
+ falseValue: "false"
184
+ },
185
+ translate: {
186
+ trueValue: "yes",
187
+ falseValue: "no"
188
+ }
189
+ };
190
+ function assignDomAttribute({ htmlElement, attributeName, value }) {
191
+ if (typeof value === "boolean") {
192
+ const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[attributeName.toLowerCase()];
193
+ if (enumeratedConfig) {
194
+ htmlElement.setAttribute(attributeName, value ? enumeratedConfig.trueValue : enumeratedConfig.falseValue);
195
+ return;
196
+ }
197
+ if (value) htmlElement.setAttribute(attributeName, "");
198
+ else htmlElement.removeAttribute(attributeName);
199
+ return;
200
+ }
201
+ htmlElement.setAttribute(attributeName, value);
202
+ }
203
+ //#endregion
171
204
  //#region src/create-element/assign-attributes.ts
172
205
  function assignAttributes({ props, htmlElement, velesNode }) {
173
206
  Object.entries(props).forEach(([key, value]) => {
@@ -185,9 +218,11 @@ function assignAttributes({ props, htmlElement, velesNode }) {
185
218
  }
186
219
  function assignAttribute({ key, value, htmlElement }) {
187
220
  if (typeof value === "function" && key.startsWith("on")) htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
188
- else if (typeof value === "boolean") {
189
- if (value) htmlElement.setAttribute(key, "");
190
- } else htmlElement.setAttribute(key, value);
221
+ else assignDomAttribute({
222
+ htmlElement,
223
+ attributeName: key,
224
+ value
225
+ });
191
226
  }
192
227
  //#endregion
193
228
  //#region src/create-element/create-element.ts
@@ -478,4 +513,4 @@ function unique(arr) {
478
513
  return resultArr;
479
514
  }
480
515
  //#endregion
481
- export { onUnmount as _, identity as a, addPublicContext as c, popPublicContext as d, Fragment as f, onMount as g, hasCurrentLifecycleContext as h, getMountedNodeExecutedVersion as i, createContext as l, createTextElement as m, callUnmountHandlers as n, renderTree as o, createElement as p, getExecutedComponentVelesNode as r, unique as s, callMountHandlers as t, getCurrentContext as u };
516
+ export { onMount as _, identity as a, addPublicContext as c, popPublicContext as d, Fragment as f, hasCurrentLifecycleContext as g, createTextElement as h, getMountedNodeExecutedVersion as i, createContext as l, assignDomAttribute as m, callUnmountHandlers as n, renderTree as o, createElement as p, getExecutedComponentVelesNode as r, unique as s, callMountHandlers as t, getCurrentContext as u, onUnmount as v };
@@ -168,6 +168,39 @@ function parseChildren({ children, htmlElement, velesNode, portal }) {
168
168
  return childComponents;
169
169
  }
170
170
  //#endregion
171
+ //#region src/attribute-utils.ts
172
+ const ENUMERATED_BOOLEAN_ATTRIBUTES = {
173
+ draggable: {
174
+ trueValue: "true",
175
+ falseValue: "false"
176
+ },
177
+ contenteditable: {
178
+ trueValue: "true",
179
+ falseValue: "false"
180
+ },
181
+ spellcheck: {
182
+ trueValue: "true",
183
+ falseValue: "false"
184
+ },
185
+ translate: {
186
+ trueValue: "yes",
187
+ falseValue: "no"
188
+ }
189
+ };
190
+ function assignDomAttribute({ htmlElement, attributeName, value }) {
191
+ if (typeof value === "boolean") {
192
+ const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[attributeName.toLowerCase()];
193
+ if (enumeratedConfig) {
194
+ htmlElement.setAttribute(attributeName, value ? enumeratedConfig.trueValue : enumeratedConfig.falseValue);
195
+ return;
196
+ }
197
+ if (value) htmlElement.setAttribute(attributeName, "");
198
+ else htmlElement.removeAttribute(attributeName);
199
+ return;
200
+ }
201
+ htmlElement.setAttribute(attributeName, value);
202
+ }
203
+ //#endregion
171
204
  //#region src/create-element/assign-attributes.ts
172
205
  function assignAttributes({ props, htmlElement, velesNode }) {
173
206
  Object.entries(props).forEach(([key, value]) => {
@@ -185,9 +218,11 @@ function assignAttributes({ props, htmlElement, velesNode }) {
185
218
  }
186
219
  function assignAttribute({ key, value, htmlElement }) {
187
220
  if (typeof value === "function" && key.startsWith("on")) htmlElement.addEventListener(key.slice(2).toLocaleLowerCase(), value);
188
- else if (typeof value === "boolean") {
189
- if (value) htmlElement.setAttribute(key, "");
190
- } else htmlElement.setAttribute(key, value);
221
+ else assignDomAttribute({
222
+ htmlElement,
223
+ attributeName: key,
224
+ value
225
+ });
191
226
  }
192
227
  //#endregion
193
228
  //#region src/create-element/create-element.ts
@@ -490,6 +525,12 @@ Object.defineProperty(exports, "addPublicContext", {
490
525
  return addPublicContext;
491
526
  }
492
527
  });
528
+ Object.defineProperty(exports, "assignDomAttribute", {
529
+ enumerable: true,
530
+ get: function() {
531
+ return assignDomAttribute;
532
+ }
533
+ });
493
534
  Object.defineProperty(exports, "callMountHandlers", {
494
535
  enumerable: true,
495
536
  get: function() {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require__utils = require("./_utils-Bhfy2AFV.cjs");
2
+ const require__utils = require("./_utils-Cf3Xvo3q.cjs");
3
3
  //#region src/attach-component.ts
4
4
  /**
5
5
  * Attach Veles component tree to a regular HTML node.
@@ -186,15 +186,17 @@ function addUseValueMountHandler({ usedValue, get, trackers, trackingSelectorEle
186
186
  function updateUseAttributeValue({ element, value }) {
187
187
  const { cb, htmlElement, attributeName, attributeValue } = element;
188
188
  const newAttributeValue = cb ? cb(value) : value;
189
- if (typeof newAttributeValue === "boolean") if (newAttributeValue) htmlElement.setAttribute(attributeName, "");
190
- else htmlElement.removeAttribute(attributeName);
191
- else if (attributeName.startsWith("on")) {
189
+ if (attributeName.startsWith("on")) {
192
190
  if (attributeValue === newAttributeValue) return;
193
191
  const eventName = attributeName.slice(2).toLocaleLowerCase();
194
192
  if (attributeValue) htmlElement.removeEventListener(eventName, attributeValue);
195
193
  if (newAttributeValue && typeof newAttributeValue === "function") htmlElement.addEventListener(eventName, newAttributeValue);
196
194
  element.attributeValue = newAttributeValue;
197
- } else htmlElement.setAttribute(attributeName, newAttributeValue);
195
+ } else require__utils.assignDomAttribute({
196
+ htmlElement,
197
+ attributeName,
198
+ value: newAttributeValue
199
+ });
198
200
  }
199
201
  //#endregion
200
202
  //#region src/create-state/update-render-each-value.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as onUnmount, a as identity, c as addPublicContext, d as popPublicContext, f as Fragment, g as onMount, h as hasCurrentLifecycleContext, i as getMountedNodeExecutedVersion, l as createContext, m as createTextElement, n as callUnmountHandlers, o as renderTree, p as createElement, r as getExecutedComponentVelesNode, s as unique, t as callMountHandlers, u as getCurrentContext } from "./_utils-kYa7oewT.js";
1
+ import { _ as onMount, a as identity, c as addPublicContext, d as popPublicContext, f as Fragment, g as hasCurrentLifecycleContext, h as createTextElement, i as getMountedNodeExecutedVersion, l as createContext, m as assignDomAttribute, n as callUnmountHandlers, o as renderTree, p as createElement, r as getExecutedComponentVelesNode, s as unique, t as callMountHandlers, u as getCurrentContext, v as onUnmount } from "./_utils-CCdioDsh.js";
2
2
  //#region src/attach-component.ts
3
3
  /**
4
4
  * Attach Veles component tree to a regular HTML node.
@@ -185,15 +185,17 @@ function addUseValueMountHandler({ usedValue, get, trackers, trackingSelectorEle
185
185
  function updateUseAttributeValue({ element, value }) {
186
186
  const { cb, htmlElement, attributeName, attributeValue } = element;
187
187
  const newAttributeValue = cb ? cb(value) : value;
188
- if (typeof newAttributeValue === "boolean") if (newAttributeValue) htmlElement.setAttribute(attributeName, "");
189
- else htmlElement.removeAttribute(attributeName);
190
- else if (attributeName.startsWith("on")) {
188
+ if (attributeName.startsWith("on")) {
191
189
  if (attributeValue === newAttributeValue) return;
192
190
  const eventName = attributeName.slice(2).toLocaleLowerCase();
193
191
  if (attributeValue) htmlElement.removeEventListener(eventName, attributeValue);
194
192
  if (newAttributeValue && typeof newAttributeValue === "function") htmlElement.addEventListener(eventName, newAttributeValue);
195
193
  element.attributeValue = newAttributeValue;
196
- } else htmlElement.setAttribute(attributeName, newAttributeValue);
194
+ } else assignDomAttribute({
195
+ htmlElement,
196
+ attributeName,
197
+ value: newAttributeValue
198
+ });
197
199
  }
198
200
  //#endregion
199
201
  //#region src/create-state/update-render-each-value.ts
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require__utils = require("./_utils-Bhfy2AFV.cjs");
2
+ const require__utils = require("./_utils-Cf3Xvo3q.cjs");
3
3
  exports.Fragment = require__utils.Fragment;
4
4
  exports.jsx = require__utils.createElement;
5
5
  exports.jsxDEV = require__utils.createElement;
@@ -1,2 +1,2 @@
1
- import { f as Fragment, p as createElement } from "./_utils-kYa7oewT.js";
1
+ import { f as Fragment, p as createElement } from "./_utils-CCdioDsh.js";
2
2
  export { Fragment, createElement as jsx, createElement as jsxDEV, createElement as jsxs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veles",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "UI library with main focus on performance",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",