@aurelia/runtime
Advanced tools
Comparing version 0.2.0-dev.20180920 to 0.2.0-dev.20180921
@@ -1,2 +0,2 @@ | ||
import { IServiceLocator } from '@aurelia/kernel'; | ||
import { IIndexable, IServiceLocator, Primitive } from '@aurelia/kernel'; | ||
import { INode } from '../dom'; | ||
@@ -16,3 +16,3 @@ import { IExpression } from './ast'; | ||
constructor(sourceExpression: IExpression, target: INode, targetProperty: string, observerLocator: IObserverLocator, locator: IServiceLocator); | ||
callSource($event: any): any; | ||
callSource(args: IIndexable): Primitive | IIndexable; | ||
$bind(flags: BindingFlags, scope: IScope): void; | ||
@@ -19,0 +19,0 @@ $unbind(flags: BindingFlags): void; |
@@ -63,11 +63,8 @@ import { IIndexable, Primitive } from '@aurelia/kernel'; | ||
} | ||
export interface PropertyAccessor extends IBindingTargetAccessor<IIndexable, string, Primitive | IIndexable> { | ||
export interface ElementPropertyAccessor extends IBindingTargetAccessor<IIndexable, string, Primitive | IIndexable> { | ||
} | ||
export declare class PropertyAccessor implements PropertyAccessor { | ||
export declare class ElementPropertyAccessor implements ElementPropertyAccessor { | ||
changeSet: IChangeSet; | ||
obj: IIndexable; | ||
propertyKey: string; | ||
currentValue: string; | ||
oldValue: string; | ||
defaultValue: string; | ||
constructor(changeSet: IChangeSet, obj: IIndexable, propertyKey: string); | ||
@@ -77,2 +74,11 @@ getValue(): Primitive | IIndexable; | ||
} | ||
export interface PropertyAccessor extends IBindingTargetAccessor<IIndexable, string, Primitive | IIndexable> { | ||
} | ||
export declare class PropertyAccessor implements PropertyAccessor { | ||
obj: IIndexable; | ||
propertyKey: string; | ||
constructor(obj: IIndexable, propertyKey: string); | ||
getValue(): Primitive | IIndexable; | ||
setValue(value: Primitive | IIndexable): void; | ||
} | ||
//# sourceMappingURL=target-accessors.d.ts.map |
{ | ||
"name": "@aurelia/runtime", | ||
"version": "0.2.0-dev.20180920", | ||
"version": "0.2.0-dev.20180921", | ||
"main": "dist/index.umd.js", | ||
@@ -46,3 +46,3 @@ "module": "dist/index.es6.js", | ||
"dependencies": { | ||
"@aurelia/kernel": "0.2.0-dev.20180920" | ||
"@aurelia/kernel": "0.2.0-dev.20180921" | ||
}, | ||
@@ -88,3 +88,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "500c64e75e90db559f90a4da7975fa2159ad62c7" | ||
"gitHead": "57c07e8ffac77dfd6cc55529d972c55016f316e8" | ||
} |
@@ -9,9 +9,16 @@ import { IServiceLocator, Reporter } from '@aurelia/kernel'; | ||
const slotNames: string[] = new Array(100); | ||
const versionSlotNames: string[] = new Array(100); | ||
for (let i = 0; i < 100; i++) { | ||
slotNames[i] = `_observer${i}`; | ||
versionSlotNames[i] = `_observerVersion${i}`; | ||
const slotNames: string[] = []; | ||
const versionSlotNames: string[] = []; | ||
let lastSlot = -1; | ||
function ensureEnoughSlotNames(currentSlot: number): void { | ||
if (currentSlot === lastSlot) { | ||
lastSlot += 5; | ||
const ii = slotNames.length = versionSlotNames.length = lastSlot + 1; | ||
for (let i = currentSlot + 1; i < ii; ++i) { | ||
slotNames[i] = `_observer${i}`; | ||
versionSlotNames[i] = `_observerVersion${i}`; | ||
} | ||
} | ||
} | ||
ensureEnoughSlotNames(-1); | ||
@@ -38,3 +45,2 @@ export interface IBinding extends IBindScope { | ||
public targetObserver: AccessorOrObserver; | ||
/*@internal*/public __connectQueueId: number; | ||
protected observerSlots: number; | ||
@@ -183,5 +189,3 @@ protected version: number; | ||
while (i-- && this[slotNames[i]] !== observer) { | ||
// Do nothing | ||
} | ||
while (i-- && this[slotNames[i]] !== observer); | ||
@@ -206,2 +210,3 @@ // if we are not already observing, put the observer in an open slot and subscribe. | ||
this[versionSlotNames[i]] = this.version; | ||
ensureEnoughSlotNames(i); | ||
} | ||
@@ -208,0 +213,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { IServiceLocator } from '@aurelia/kernel'; | ||
import { IIndexable, IServiceLocator, Primitive } from '@aurelia/kernel'; | ||
import { INode } from '../dom'; | ||
@@ -24,10 +24,8 @@ import { IExpression } from './ast'; | ||
public callSource($event) { | ||
let overrideContext = <any>this.$scope.overrideContext; | ||
Object.assign(overrideContext, $event); | ||
overrideContext.$event = $event; // deprecate this? | ||
let result = this.sourceExpression.evaluate(BindingFlags.mustEvaluate, this.$scope, this.locator); | ||
delete overrideContext.$event; | ||
public callSource(args: IIndexable): Primitive | IIndexable { | ||
const overrideContext = this.$scope.overrideContext; | ||
Object.assign(overrideContext, args); | ||
const result = this.sourceExpression.evaluate(BindingFlags.mustEvaluate, this.$scope, this.locator); | ||
for (let prop in $event) { | ||
for (const prop in args) { | ||
delete overrideContext[prop]; | ||
@@ -39,3 +37,3 @@ } | ||
public $bind(flags: BindingFlags, scope: IScope) { | ||
public $bind(flags: BindingFlags, scope: IScope): void { | ||
if (this.$isBound) { | ||
@@ -56,6 +54,6 @@ if (this.$scope === scope) { | ||
this.targetObserver.setValue($event => this.callSource($event), flags); | ||
this.targetObserver.setValue($args => this.callSource($args), flags); | ||
} | ||
public $unbind(flags: BindingFlags) { | ||
public $unbind(flags: BindingFlags): void { | ||
if (!this.$isBound) { | ||
@@ -75,3 +73,4 @@ return; | ||
public observeProperty() { } | ||
// tslint:disable-next-line:no-empty | ||
public observeProperty(): void { } | ||
} |
@@ -14,3 +14,3 @@ import { DI, IIndexable, inject, Primitive, Reporter } from '@aurelia/kernel'; | ||
import { ISVGAnalyzer } from './svg-analyzer'; | ||
import { ClassAttributeAccessor, DataAttributeAccessor, PropertyAccessor, StyleAttributeAccessor, XLinkAttributeAccessor } from './target-accessors'; | ||
import { ClassAttributeAccessor, DataAttributeAccessor, PropertyAccessor, StyleAttributeAccessor, XLinkAttributeAccessor, ElementPropertyAccessor } from './target-accessors'; | ||
@@ -88,3 +88,8 @@ const toStringTag = Object.prototype.toString; | ||
const tagName = obj['tagName']; | ||
// this check comes first for hot path optimization | ||
if (propertyName === 'textContent') { | ||
return new ElementPropertyAccessor(this.changeSet, obj, propertyName); | ||
} | ||
// TODO: optimize and make pluggable | ||
if (propertyName === 'class' || propertyName === 'style' || propertyName === 'css' | ||
@@ -105,5 +110,6 @@ || propertyName === 'value' && (tagName === 'INPUT' || tagName === 'SELECT') | ||
} | ||
return new ElementPropertyAccessor(this.changeSet, obj, propertyName); | ||
} | ||
return new PropertyAccessor(this.changeSet, obj, propertyName); | ||
return new PropertyAccessor(obj, propertyName); | ||
} | ||
@@ -110,0 +116,0 @@ |
import { IIndexable, Primitive } from '@aurelia/kernel'; | ||
import { DOM, INode } from '../dom'; | ||
import { IChangeSet } from './change-set'; | ||
import { IBindingTargetAccessor } from './observation'; | ||
import { IBindingTargetAccessor, MutationKind } from './observation'; | ||
import { targetObserver } from './target-observer'; | ||
import { subscriberCollection } from './subscriber-collection'; | ||
@@ -233,17 +234,23 @@ // tslint:disable-next-line:no-http-string | ||
// tslint:disable-next-line:interface-name | ||
export interface ElementPropertyAccessor extends IBindingTargetAccessor<IIndexable, string, Primitive | IIndexable> {} | ||
@targetObserver('') | ||
export class ElementPropertyAccessor implements ElementPropertyAccessor { | ||
constructor(public changeSet: IChangeSet, public obj: IIndexable, public propertyKey: string) { } | ||
public getValue(): Primitive | IIndexable { | ||
return this.obj[this.propertyKey]; | ||
} | ||
public setValueCore(value: Primitive | IIndexable): void { | ||
this.obj[this.propertyKey] = value; | ||
} | ||
} | ||
// tslint:disable-next-line:interface-name | ||
export interface PropertyAccessor extends IBindingTargetAccessor<IIndexable, string, Primitive | IIndexable> {} | ||
@targetObserver() | ||
export class PropertyAccessor implements PropertyAccessor { | ||
public currentValue: string; | ||
public oldValue: string; | ||
public defaultValue: string; | ||
constructor(public obj: IIndexable, public propertyKey: string) { } | ||
constructor( | ||
public changeSet: IChangeSet, | ||
public obj: IIndexable, | ||
public propertyKey: string) { | ||
this.oldValue = this.currentValue = obj[propertyKey]; | ||
} | ||
public getValue(): Primitive | IIndexable { | ||
@@ -253,5 +260,5 @@ return this.obj[this.propertyKey]; | ||
public setValueCore(value: Primitive | IIndexable): void { | ||
public setValue(value: Primitive | IIndexable): void { | ||
this.obj[this.propertyKey] = value; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2059828
23027
+ Added@aurelia/kernel@0.2.0-dev.20180921(transitive)
- Removed@aurelia/kernel@0.2.0-dev.20180920(transitive)