svelte-common 6.8.1 → 6.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "6.8.1",
3
+ "version": "6.8.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/attribute.mjs CHANGED
@@ -232,44 +232,8 @@ export function setAttribute(object, name, value) {
232
232
  * @param {string} name
233
233
  * @returns {any} value associated with the given property name
234
234
  */
235
- export function getAttribute(object, name) {
236
- if (object?.[name] !== undefined) {
237
- return object[name];
238
- }
239
-
240
- let predicateTokens;
241
-
242
- for (const token of tokens(name)) {
243
- switch (token) {
244
- case ">":
245
- case "<":
246
- case ".":
247
- break;
248
- case "[":
249
- predicateTokens = [];
250
- break;
251
- case "]":
252
- // TODO: should loop over array actually getAttribute api should deliver iterators
253
- if (Array.isArray(object)) {
254
- object = object[0];
255
- }
256
-
257
- predicateTokens = undefined;
258
- break;
259
- case "*":
260
- predicateTokens.push(token);
261
- break;
262
-
263
- default:
264
- if (object === undefined) {
265
- break;
266
- }
267
-
268
- object = object[token];
269
- }
270
- }
271
-
272
- return object;
235
+ export function getAttribute(object, expression) {
236
+ return getAttributeAndOperator(object, expression)[0];
273
237
  }
274
238
 
275
239
  /**
@@ -281,7 +245,6 @@ export function getAttribute(object, name) {
281
245
  */
282
246
  export function getAttributeAndOperator(object, expression, getters = {}) {
283
247
  let op = "=";
284
-
285
248
  let predicateTokens;
286
249
 
287
250
  for (const token of tokens(expression)) {
@@ -303,6 +266,10 @@ export function getAttributeAndOperator(object, expression, getters = {}) {
303
266
  if (Array.isArray(object)) {
304
267
  object = object[0];
305
268
  }
269
+ else {
270
+ if(object[Symbol.iterator])
271
+ object = [...object][0];
272
+ }
306
273
 
307
274
  predicateTokens = undefined;
308
275
  break;
@@ -209,6 +209,7 @@ export class Pagination {
209
209
  a.onclick = e => {
210
210
  e.preventDefault();
211
211
  e.stopPropagation();
212
+ nav.focus();
212
213
  this.page = targetPage;
213
214
  };
214
215
  }