@fluffjs/fluff 0.2.1 → 0.2.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": "@fluffjs/fluff",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -25,10 +25,10 @@ export declare abstract class FluffBase extends HTMLElement {
25
25
  __loopContext: Record<string, unknown>;
26
26
  protected __baseSubscriptions: Subscription[];
27
27
  __getScope(): Scope;
28
- protected __processBindingsOnElement(el: HTMLElement, scope: Scope, subscriptions?: Subscription[]): void;
28
+ protected __processBindingsOnElement(el: Element, scope: Scope, subscriptions?: Subscription[]): void;
29
29
  private __getBindingsForLid;
30
30
  private __isBindingsMap;
31
- protected __applyBindingWithScope(el: HTMLElement, binding: BindingInfo, scope: Scope, subscriptions?: Subscription[]): void;
31
+ protected __applyBindingWithScope(el: Element, binding: BindingInfo, scope: Scope, subscriptions?: Subscription[]): void;
32
32
  protected __getCompiledExprFn(exprId: number): ExpressionFn;
33
33
  protected __getCompiledHandlerFn(handlerId: number): HandlerFn;
34
34
  protected __applyPipes(value: unknown, pipes: {
@@ -49,4 +49,5 @@ export declare abstract class FluffBase extends HTMLElement {
49
49
  private __applyTwoWayBindingWithScope;
50
50
  private __applyClassBindingWithScope;
51
51
  private __applyStyleBindingWithScope;
52
+ private __hasStyle;
52
53
  }
@@ -1,4 +1,3 @@
1
- import { DomUtils } from '../utils/DomUtils.js';
2
1
  import { Property } from '../utils/Property.js';
3
2
  import { Publisher } from '../utils/Publisher.js';
4
3
  export class FluffBase extends HTMLElement {
@@ -221,14 +220,7 @@ export class FluffBase extends HTMLElement {
221
220
  if (prop instanceof Property) {
222
221
  prop.setValue(value, true);
223
222
  }
224
- else if (DomUtils.isCustomElement(el)) {
225
- this.__whenDefined(el.tagName.toLowerCase(), () => {
226
- if (el instanceof FluffBase) {
227
- Reflect.set(el, propName, value);
228
- }
229
- });
230
- }
231
- else if (propName in el) {
223
+ else if (propName in el && el instanceof HTMLElement) {
232
224
  Reflect.set(el, propName, value);
233
225
  }
234
226
  else {
@@ -374,7 +366,9 @@ export class FluffBase extends HTMLElement {
374
366
  }
375
367
  const fn = this.__getCompiledExprFn(binding.e);
376
368
  const value = fn(this, scope.locals);
377
- el.style.setProperty(binding.n, String(value));
369
+ if (this.__hasStyle(el)) {
370
+ el.style.setProperty(binding.n, String(value));
371
+ }
378
372
  }
379
373
  catch (e) {
380
374
  console.error('Style binding error:', e);
@@ -383,4 +377,7 @@ export class FluffBase extends HTMLElement {
383
377
  this.__subscribeToExpressionInScope(binding.d, scope, update, subscriptions);
384
378
  update();
385
379
  }
380
+ __hasStyle(el) {
381
+ return 'style' in el;
382
+ }
386
383
  }
@@ -16,7 +16,7 @@ export declare abstract class FluffElement extends FluffBase {
16
16
  connectedCallback(): void;
17
17
  disconnectedCallback(): void;
18
18
  $watch: (_properties: string[], callback: (changed: string) => void) => Subscription;
19
- __processBindingsOnElementPublic(el: HTMLElement, scope: Scope, subscriptions?: Subscription[]): void;
19
+ __processBindingsOnElementPublic(el: Element, scope: Scope, subscriptions?: Subscription[]): void;
20
20
  protected abstract __render(): void;
21
21
  protected __setupBindings(): void;
22
22
  protected __addSubscription(sub: Subscription): void;
@@ -200,16 +200,7 @@ export class FluffElement extends FluffBase {
200
200
  return;
201
201
  }
202
202
  }
203
- const prop = Reflect.get(el, propName);
204
- if (prop instanceof Property) {
205
- prop.setValue(value, true);
206
- }
207
- else if (propName in el) {
208
- Reflect.set(el, propName, value);
209
- }
210
- else {
211
- el.setAttribute(propName, String(value));
212
- }
203
+ super.__setChildProperty(el, propName, value);
213
204
  }
214
205
  __bindToChild(id, propName, value) {
215
206
  const el = this.__getElement(id);
@@ -272,9 +263,7 @@ export class FluffElement extends FluffBase {
272
263
  const closestComponent = el.closest('[x-fluff-component]');
273
264
  if (closestComponent && closestComponent !== el)
274
265
  continue;
275
- if (el instanceof HTMLElement) {
276
- this.__processBindingsOnElement(el, scope);
277
- }
266
+ this.__processBindingsOnElement(el, scope);
278
267
  }
279
268
  }
280
269
  __applyPendingProps() {
@@ -1 +0,0 @@
1
- export declare function InputProperty(): PropertyDecorator;
@@ -1,4 +0,0 @@
1
- export function InputProperty() {
2
- return (_target, _propertyKey) => {
3
- };
4
- }