veles 1.1.0 → 1.1.1

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.
@@ -169,6 +169,11 @@ function parseChildren({ children, htmlElement, velesNode, portal }) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/attribute-utils.ts
172
+ const FORM_VALUE_TAGS = new Set([
173
+ "INPUT",
174
+ "TEXTAREA",
175
+ "SELECT"
176
+ ]);
172
177
  const ENUMERATED_BOOLEAN_ATTRIBUTES = {
173
178
  draggable: {
174
179
  trueValue: "true",
@@ -188,6 +193,19 @@ const ENUMERATED_BOOLEAN_ATTRIBUTES = {
188
193
  }
189
194
  };
190
195
  function assignDomAttribute({ htmlElement, attributeName, value, previousValue }) {
196
+ const normalizedAttributeName = attributeName.toLowerCase();
197
+ if (normalizedAttributeName === "value" && isFormValueElement(htmlElement)) {
198
+ assignFormValueProperty(htmlElement, value);
199
+ return;
200
+ }
201
+ if (normalizedAttributeName === "checked" && htmlElement.tagName === "INPUT") {
202
+ assignBooleanProperty(htmlElement, "checked", value);
203
+ return;
204
+ }
205
+ if (normalizedAttributeName === "selected" && htmlElement.tagName === "OPTION") {
206
+ assignBooleanProperty(htmlElement, "selected", value);
207
+ return;
208
+ }
191
209
  if (attributeName === "style") {
192
210
  assignStyle({
193
211
  value,
@@ -197,7 +215,7 @@ function assignDomAttribute({ htmlElement, attributeName, value, previousValue }
197
215
  return;
198
216
  }
199
217
  if (typeof value === "boolean") {
200
- const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[attributeName.toLowerCase()];
218
+ const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[normalizedAttributeName];
201
219
  if (enumeratedConfig) {
202
220
  htmlElement.setAttribute(attributeName, value ? enumeratedConfig.trueValue : enumeratedConfig.falseValue);
203
221
  return;
@@ -212,6 +230,25 @@ function assignDomAttribute({ htmlElement, attributeName, value, previousValue }
212
230
  }
213
231
  htmlElement.setAttribute(attributeName, value);
214
232
  }
233
+ function isFormValueElement(htmlElement) {
234
+ return FORM_VALUE_TAGS.has(htmlElement.tagName);
235
+ }
236
+ function assignFormValueProperty(htmlElement, value) {
237
+ if (htmlElement.tagName === "SELECT" && Array.isArray(value)) {
238
+ const selectedValues = new Set(value.map(String));
239
+ Array.from(htmlElement.options).forEach((option) => {
240
+ const shouldSelect = selectedValues.has(option.value);
241
+ if (option.selected !== shouldSelect) option.selected = shouldSelect;
242
+ });
243
+ return;
244
+ }
245
+ const normalizedValue = value == null ? "" : String(value);
246
+ if (htmlElement.value !== normalizedValue) htmlElement.value = normalizedValue;
247
+ }
248
+ function assignBooleanProperty(htmlElement, propertyName, value) {
249
+ const normalizedValue = Boolean(value);
250
+ if (htmlElement[propertyName] !== normalizedValue) htmlElement[propertyName] = normalizedValue;
251
+ }
215
252
  function assignStyle({ value, previousValue, htmlElement }) {
216
253
  if (value == null) {
217
254
  htmlElement.style.cssText = "";
@@ -169,6 +169,11 @@ function parseChildren({ children, htmlElement, velesNode, portal }) {
169
169
  }
170
170
  //#endregion
171
171
  //#region src/attribute-utils.ts
172
+ const FORM_VALUE_TAGS = new Set([
173
+ "INPUT",
174
+ "TEXTAREA",
175
+ "SELECT"
176
+ ]);
172
177
  const ENUMERATED_BOOLEAN_ATTRIBUTES = {
173
178
  draggable: {
174
179
  trueValue: "true",
@@ -188,6 +193,19 @@ const ENUMERATED_BOOLEAN_ATTRIBUTES = {
188
193
  }
189
194
  };
190
195
  function assignDomAttribute({ htmlElement, attributeName, value, previousValue }) {
196
+ const normalizedAttributeName = attributeName.toLowerCase();
197
+ if (normalizedAttributeName === "value" && isFormValueElement(htmlElement)) {
198
+ assignFormValueProperty(htmlElement, value);
199
+ return;
200
+ }
201
+ if (normalizedAttributeName === "checked" && htmlElement.tagName === "INPUT") {
202
+ assignBooleanProperty(htmlElement, "checked", value);
203
+ return;
204
+ }
205
+ if (normalizedAttributeName === "selected" && htmlElement.tagName === "OPTION") {
206
+ assignBooleanProperty(htmlElement, "selected", value);
207
+ return;
208
+ }
191
209
  if (attributeName === "style") {
192
210
  assignStyle({
193
211
  value,
@@ -197,7 +215,7 @@ function assignDomAttribute({ htmlElement, attributeName, value, previousValue }
197
215
  return;
198
216
  }
199
217
  if (typeof value === "boolean") {
200
- const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[attributeName.toLowerCase()];
218
+ const enumeratedConfig = ENUMERATED_BOOLEAN_ATTRIBUTES[normalizedAttributeName];
201
219
  if (enumeratedConfig) {
202
220
  htmlElement.setAttribute(attributeName, value ? enumeratedConfig.trueValue : enumeratedConfig.falseValue);
203
221
  return;
@@ -212,6 +230,25 @@ function assignDomAttribute({ htmlElement, attributeName, value, previousValue }
212
230
  }
213
231
  htmlElement.setAttribute(attributeName, value);
214
232
  }
233
+ function isFormValueElement(htmlElement) {
234
+ return FORM_VALUE_TAGS.has(htmlElement.tagName);
235
+ }
236
+ function assignFormValueProperty(htmlElement, value) {
237
+ if (htmlElement.tagName === "SELECT" && Array.isArray(value)) {
238
+ const selectedValues = new Set(value.map(String));
239
+ Array.from(htmlElement.options).forEach((option) => {
240
+ const shouldSelect = selectedValues.has(option.value);
241
+ if (option.selected !== shouldSelect) option.selected = shouldSelect;
242
+ });
243
+ return;
244
+ }
245
+ const normalizedValue = value == null ? "" : String(value);
246
+ if (htmlElement.value !== normalizedValue) htmlElement.value = normalizedValue;
247
+ }
248
+ function assignBooleanProperty(htmlElement, propertyName, value) {
249
+ const normalizedValue = Boolean(value);
250
+ if (htmlElement[propertyName] !== normalizedValue) htmlElement[propertyName] = normalizedValue;
251
+ }
215
252
  function assignStyle({ value, previousValue, htmlElement }) {
216
253
  if (value == null) {
217
254
  htmlElement.style.cssText = "";
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require__utils = require("./_utils-DMl2JD2g.cjs");
2
+ const require__utils = require("./_utils-DnT1tr2L.cjs");
3
3
  //#region src/attach-component.ts
4
4
  /**
5
5
  * Attach Veles component tree to a regular HTML node.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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-klvxkUOR.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-DxfFNKLL.js";
2
2
  //#region src/attach-component.ts
3
3
  /**
4
4
  * Attach Veles component tree to a regular HTML node.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require__utils = require("./_utils-DMl2JD2g.cjs");
2
+ const require__utils = require("./_utils-DnT1tr2L.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-klvxkUOR.js";
1
+ import { f as Fragment, p as createElement } from "./_utils-DxfFNKLL.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.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "UI library with main focus on performance",
5
5
  "keywords": [
6
6
  "JavaScript",