Skip to content

Commit

Permalink
fix: bind relies on existing datacontext helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
npenin committed Sep 5, 2024
1 parent 877f4dc commit 911c7fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/client/src/controlsv2/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Control<TBindings extends Record<string, unknown> = Record<string,
if (this.bindings[name] && oldValue != newValue)
{
const oldBinding = this.bindings[name];
this.bindings[name] = new Binding({ controller: this, get context() { return DataContext.find(this.element) } }, Parser.parameterLess.parse(newValue));
this.bindings[name] = DataContext.find(this.element).pipe(Parser.parameterLess.parse(newValue));
this.bindings[name].set('change', (oldBinding.get('change') as Event<[{ oldValue: TBindings[TKey], value: TBindings[TKey] }]>).clone())
this.bindings[name].emit('change', { value: this.bindings[name].getValue(), oldValue: oldBinding.getValue() })
oldBinding[Symbol.dispose]();
Expand All @@ -35,11 +35,11 @@ export class Control<TBindings extends Record<string, unknown> = Record<string,
if (!Reflect.has(this.element, 'controller'))
{
// const controllerBinding = this.teardown(Binding.defineProperty(this.element, 'controller'));
return this.teardown(this.bindings[attributeName] = new Binding(DataContext.find(this.element), Parser.parameterLess.parse(attributeValue || '')));
return this.teardown(this.bindings[attributeName] = DataContext.find(this.element).pipe(Parser.parameterLess.parse(attributeValue || '')));

}
if (!this.bindings[attributeName])
return this.teardown(this.bindings[attributeName] = new Binding({ controller: this.element['controller'], get context() { return DataContext.find(this.element) } }, Parser.parameterLess.parse(attributeValue || '')));
return this.teardown(this.bindings[attributeName] = DataContext.extend(DataContext.find(this.element), { controller: this.element['controller'] }).pipe(Parser.parameterLess.parse(attributeValue || '')));
return this.bindings[attributeName];
}
}

0 comments on commit 911c7fb

Please sign in to comment.