@fluffjs/fluff 0.1.8 → 0.1.10
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 +1 -1
- package/runtime/FluffBase.js +3 -0
- package/runtime/FluffElementImpl.d.ts +1 -1
- package/runtime/FluffElementImpl.js +4 -4
- package/runtime/tests/TestDirectChildComponent.d.ts +6 -0
- package/runtime/tests/TestDirectChildComponent.js +10 -0
- package/runtime/tests/TestDirectParentComponent.d.ts +6 -0
- package/runtime/tests/TestDirectParentComponent.js +10 -0
- package/runtime/tests/TestPropertyUnwrapChildComponent.d.ts +10 -0
- package/runtime/tests/TestPropertyUnwrapChildComponent.js +19 -0
- package/runtime/tests/TestPropertyUnwrapContainerClass.d.ts +4 -0
- package/runtime/tests/TestPropertyUnwrapContainerClass.js +4 -0
- package/runtime/tests/TestPropertyUnwrapParentComponent.d.ts +9 -0
- package/runtime/tests/TestPropertyUnwrapParentComponent.js +19 -0
package/package.json
CHANGED
package/runtime/FluffBase.js
CHANGED
|
@@ -158,6 +158,9 @@ export class FluffBase extends HTMLElement {
|
|
|
158
158
|
if (el instanceof FluffBase) {
|
|
159
159
|
update();
|
|
160
160
|
}
|
|
161
|
+
else {
|
|
162
|
+
console.warn(`Element <${tagName}> is not a FluffBase instance after whenDefined - binding for "${binding.n}" skipped`);
|
|
163
|
+
}
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
}
|
|
@@ -15,7 +15,7 @@ export declare abstract class FluffElement extends FluffBase {
|
|
|
15
15
|
constructor();
|
|
16
16
|
connectedCallback(): void;
|
|
17
17
|
disconnectedCallback(): void;
|
|
18
|
-
$watch: (_properties: string[], callback: () => void) => Subscription;
|
|
18
|
+
$watch: (_properties: string[], callback: (changed: string) => void) => Subscription;
|
|
19
19
|
__processBindingsOnElementPublic(el: HTMLElement, scope: Scope, subscriptions?: Subscription[]): void;
|
|
20
20
|
protected abstract __render(): void;
|
|
21
21
|
protected __setupBindings(): void;
|
|
@@ -62,7 +62,7 @@ export class FluffElement extends FluffBase {
|
|
|
62
62
|
this.__baseSubscriptions = [];
|
|
63
63
|
}
|
|
64
64
|
$watch = (_properties, callback) => {
|
|
65
|
-
callback();
|
|
65
|
+
callback('');
|
|
66
66
|
return {
|
|
67
67
|
unsubscribe: () => {
|
|
68
68
|
}
|
|
@@ -187,6 +187,9 @@ export class FluffElement extends FluffBase {
|
|
|
187
187
|
this.__bindOutputOnElement(el, outputName, handler);
|
|
188
188
|
}
|
|
189
189
|
__setChildProperty(el, propName, value) {
|
|
190
|
+
if (value instanceof Property) {
|
|
191
|
+
value = value.getValue();
|
|
192
|
+
}
|
|
190
193
|
if (el instanceof HTMLElement && el.hasAttribute('x-fluff-component')) {
|
|
191
194
|
const tagName = el.tagName.toLowerCase();
|
|
192
195
|
if (customElements.get(tagName) === undefined) {
|
|
@@ -269,9 +272,6 @@ export class FluffElement extends FluffBase {
|
|
|
269
272
|
if (closestComponent && closestComponent !== el)
|
|
270
273
|
continue;
|
|
271
274
|
if (el instanceof HTMLElement) {
|
|
272
|
-
const tagName = el.tagName.toLowerCase();
|
|
273
|
-
if (customElements.get(tagName))
|
|
274
|
-
continue;
|
|
275
275
|
this.__processBindingsOnElement(el, scope);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FluffElement } from '../FluffElement.js';
|
|
2
|
+
export class TestDirectChildComponent extends FluffElement {
|
|
3
|
+
value = '';
|
|
4
|
+
__render() {
|
|
5
|
+
this.__getShadowRoot().innerHTML = `<span class="value">${this.value}</span>`;
|
|
6
|
+
}
|
|
7
|
+
__setupBindings() {
|
|
8
|
+
super.__setupBindings();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FluffElement } from '../FluffElement.js';
|
|
2
|
+
export class TestDirectParentComponent extends FluffElement {
|
|
3
|
+
itemName = 'test-item';
|
|
4
|
+
__render() {
|
|
5
|
+
this.__getShadowRoot().innerHTML = '<test-direct-child data-lid="l0" x-fluff-component></test-direct-child>';
|
|
6
|
+
}
|
|
7
|
+
__setupBindings() {
|
|
8
|
+
super.__setupBindings();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Property } from '../../utils/Property.js';
|
|
2
|
+
import { FluffElement } from '../FluffElement.js';
|
|
3
|
+
export declare let testPropertyUnwrapReceivedValue: number | null;
|
|
4
|
+
export declare function resetTestPropertyUnwrapReceivedValue(): void;
|
|
5
|
+
export declare class TestPropertyUnwrapChildComponent extends FluffElement {
|
|
6
|
+
__property: Property<number | null>;
|
|
7
|
+
get property(): number | null;
|
|
8
|
+
set property(val: number | null);
|
|
9
|
+
protected __render(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Property } from '../../utils/Property.js';
|
|
2
|
+
import { FluffElement } from '../FluffElement.js';
|
|
3
|
+
export let testPropertyUnwrapReceivedValue = null;
|
|
4
|
+
export function resetTestPropertyUnwrapReceivedValue() {
|
|
5
|
+
testPropertyUnwrapReceivedValue = null;
|
|
6
|
+
}
|
|
7
|
+
export class TestPropertyUnwrapChildComponent extends FluffElement {
|
|
8
|
+
__property = new Property({ initialValue: null, propertyName: 'property' });
|
|
9
|
+
get property() {
|
|
10
|
+
return this.__property.getValue();
|
|
11
|
+
}
|
|
12
|
+
set property(val) {
|
|
13
|
+
testPropertyUnwrapReceivedValue = val;
|
|
14
|
+
this.__property.setValue(val);
|
|
15
|
+
}
|
|
16
|
+
__render() {
|
|
17
|
+
this.__getShadowRoot().innerHTML = '<span></span>';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Property } from '../../utils/Property.js';
|
|
2
|
+
import { FluffElement } from '../FluffElement.js';
|
|
3
|
+
import { TestPropertyUnwrapContainerClass } from './TestPropertyUnwrapContainerClass.js';
|
|
4
|
+
export declare class TestPropertyUnwrapParentComponent extends FluffElement {
|
|
5
|
+
__hostClass: Property<TestPropertyUnwrapContainerClass>;
|
|
6
|
+
get hostClass(): TestPropertyUnwrapContainerClass;
|
|
7
|
+
set hostClass(val: TestPropertyUnwrapContainerClass);
|
|
8
|
+
protected __render(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Property } from '../../utils/Property.js';
|
|
2
|
+
import { FluffElement } from '../FluffElement.js';
|
|
3
|
+
import { TestPropertyUnwrapContainerClass } from './TestPropertyUnwrapContainerClass.js';
|
|
4
|
+
export class TestPropertyUnwrapParentComponent extends FluffElement {
|
|
5
|
+
__hostClass = new Property({ initialValue: new TestPropertyUnwrapContainerClass(), propertyName: 'hostClass' });
|
|
6
|
+
get hostClass() {
|
|
7
|
+
const val = this.__hostClass.getValue();
|
|
8
|
+
if (!val) {
|
|
9
|
+
throw new Error('hostClass is null');
|
|
10
|
+
}
|
|
11
|
+
return val;
|
|
12
|
+
}
|
|
13
|
+
set hostClass(val) {
|
|
14
|
+
this.__hostClass.setValue(val);
|
|
15
|
+
}
|
|
16
|
+
__render() {
|
|
17
|
+
this.__getShadowRoot().innerHTML = '<test-prop-unwrap-child data-lid="l0"></test-prop-unwrap-child>';
|
|
18
|
+
}
|
|
19
|
+
}
|