Skip to content

Commit

Permalink
feat(attr-binding-behavior): port from vCurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Apr 23, 2018
1 parent 5ba5234 commit 1d3478e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ An experimental re-working of Aurelia, oriented around compile-time reflection a

### Resources

* [x] `attr` Binding Behavior
* [x] `if` Template Controller
* [x] `else` Template Controller
* [x] `compose` Custom Element
* [ ] `repeat` Template Controller
* [x] `compose` Custom Element

### Application Model

Expand Down
32 changes: 29 additions & 3 deletions scripts/app-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/app-bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/runtime/binding/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class BindingBehavior implements IExpression {
}

bind(binding: IBinding, scope: IScope) {
if ((this.expression as any)['expression'] && this.expression.bind) {
if ((this.expression as any).expression && this.expression.bind) {
this.expression.bind(binding, scope);
}

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/binding/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export interface IBinding extends IBindScope {
export type IBindingTarget = any; // Node | CSSStyleDeclaration | IObservable;

export class Binding extends ConnectableBinding implements IBinding {
private targetObserver: IBindingTargetObserver | IBindingTargetAccessor;
public targetObserver: IBindingTargetObserver | IBindingTargetAccessor;
private source: IScope;
private isBound = false;

constructor(
private sourceExpression: IExpression,
private target: IBindingTarget,
private targetProperty: string,
public target: IBindingTarget,
public targetProperty: string,
private mode: number,
public container: IContainer) {
super();
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/configuration/standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import { IEventManager, EventManager } from "../binding/event-manager";
import { IObserverLocator, ObserverLocator } from "../binding/observer-locator";
import { IAnimator, Animator } from "../templating/animator";
import { Compose } from "../resources/compose";
import { AttrBindingBehavior } from "../resources/attr-binding-behavior";

export const StandardConfiguration = {
register(container: IContainer) {
container.register(
AttrBindingBehavior,

If,
Else,

Compose
);

Expand Down
14 changes: 14 additions & 0 deletions src/runtime/resources/attr-binding-behavior.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DataAttributeObserver } from '../binding/element-observation';
import { bindingBehavior } from '../decorators';
import { Binding } from '../binding/binding';
import { IScope } from '../binding/binding-context';

//TODO: extract an interface for use in implementing binding behaviors.
@bindingBehavior('attr')
export class AttrBindingBehavior {
bind(binding: Binding, scope: IScope) {
binding.targetObserver = new DataAttributeObserver(binding.target, binding.targetProperty);
}

unbind(binding: Binding, scope: IScope) {}
}

0 comments on commit 1d3478e

Please sign in to comment.