From 7921f55ea7ee4ae38fd36f7df53405d47a89d038 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Tue, 10 Nov 2015 09:52:37 -0500 Subject: [PATCH] chore(all): prepare release 0.17.0 --- bower.json | 2 +- config.js | 13 +- dist/amd/aurelia-templating-binding.d.ts | 30 +- dist/amd/aurelia-templating-binding.js | 304 +++++---- dist/aurelia-templating-binding.d.ts | 30 +- dist/aurelia-templating-binding.js | 296 +++++---- dist/commonjs/aurelia-templating-binding.d.ts | 30 +- dist/commonjs/aurelia-templating-binding.js | 304 +++++---- dist/es6/aurelia-templating-binding.d.ts | 30 +- dist/es6/aurelia-templating-binding.js | 296 +++++---- dist/system/aurelia-templating-binding.d.ts | 30 +- dist/system/aurelia-templating-binding.js | 310 +++++---- doc/CHANGELOG.md | 14 + doc/api.json | 607 ++++++++++++------ package.json | 8 +- 15 files changed, 1414 insertions(+), 890 deletions(-) diff --git a/bower.json b/bower.json index ac90641..ee22478 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-binding", - "version": "0.16.1", + "version": "0.17.0", "description": "An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.", "keywords": [ "aurelia", diff --git a/config.js b/config.js index 5529ea5..161e729 100644 --- a/config.js +++ b/config.js @@ -16,9 +16,9 @@ System.config({ map: { "aurelia-binding": "github:aurelia/binding@0.11.0", "aurelia-logging": "github:aurelia/logging@0.9.0", - "aurelia-pal": "github:aurelia/pal@0.2.0", - "aurelia-pal-browser": "github:aurelia/pal-browser@0.2.0", - "aurelia-task-queue": "github:aurelia/task-queue@0.8.0", + "aurelia-pal": "github:aurelia/pal@0.3.0", + "aurelia-pal-browser": "github:aurelia/pal-browser@0.3.0", + "aurelia-task-queue": "github:aurelia/task-queue@0.9.0", "aurelia-templating": "github:aurelia/templating@0.17.0", "babel": "npm:babel-core@5.8.23", "babel-runtime": "npm:babel-runtime@5.8.20", @@ -43,11 +43,8 @@ System.config({ "aurelia-pal": "github:aurelia/pal@0.3.0", "core-js": "npm:core-js@1.2.6" }, - "github:aurelia/pal-browser@0.2.0": { - "aurelia-pal": "github:aurelia/pal@0.2.0" - }, - "github:aurelia/task-queue@0.8.0": { - "aurelia-pal": "github:aurelia/pal@0.2.0" + "github:aurelia/pal-browser@0.3.0": { + "aurelia-pal": "github:aurelia/pal@0.3.0" }, "github:aurelia/task-queue@0.9.0": { "aurelia-pal": "github:aurelia/pal@0.3.0" diff --git a/dist/amd/aurelia-templating-binding.d.ts b/dist/amd/aurelia-templating-binding.d.ts index 6bf2813..4a348ef 100644 --- a/dist/amd/aurelia-templating-binding.d.ts +++ b/dist/amd/aurelia-templating-binding.d.ts @@ -1,7 +1,24 @@ declare module 'aurelia-templating-binding' { import * as LogManager from 'aurelia-logging'; - import { Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable } from 'aurelia-binding'; + import { bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression } from 'aurelia-binding'; import { BehaviorInstruction, BindingLanguage } from 'aurelia-templating'; + export class InterpolationBindingExpression { + constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, lookupFunctions: any, attribute: any); + createBinding(target: any): any; + } + export class InterpolationBinding { + constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, lookupFunctions: any); + interpolate(): any; + bind(source: any): any; + unbind(): any; + } + export class ChildInterpolationBinding { + constructor(parent: any, observerLocator: any, sourceExpression: any, mode: any, lookupFunctions: any); + updateTarget(value: any): any; + call(): any; + bind(source: any): any; + unbind(): any; + } /*eslint dot-notation:0*/ export class SyntaxInterpreter { @@ -28,16 +45,5 @@ declare module 'aurelia-templating-binding' { parseText(resources: any, value: any): any; parseContent(resources: any, attrName: any, attrValue: any): any; } - export class InterpolationBindingExpression { - constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, valueConverterLookupFunction: any, attribute: any); - createBinding(target: any): any; - } - class InterpolationBinding { - constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, valueConverterLookupFunction: any); - bind(source: any): any; - call(): any; - interpolate(connect: any, initial: any): any; - unbind(): any; - } export function configure(config: any): any; } \ No newline at end of file diff --git a/dist/amd/aurelia-templating-binding.js b/dist/amd/aurelia-templating-binding.js index 7ad54e6..0c884c1 100644 --- a/dist/amd/aurelia-templating-binding.js +++ b/dist/amd/aurelia-templating-binding.js @@ -8,6 +8,175 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + var InterpolationBindingExpression = (function () { + function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, lookupFunctions, attribute) { + _classCallCheck(this, InterpolationBindingExpression); + + this.observerLocator = observerLocator; + this.targetProperty = targetProperty; + this.parts = parts; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + this.attribute = this.attrToRemove = attribute; + this.discrete = false; + } + + InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { + return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.lookupFunctions); + }; + + return InterpolationBindingExpression; + })(); + + exports.InterpolationBindingExpression = InterpolationBindingExpression; + + var InterpolationBinding = (function () { + function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, lookupFunctions) { + _classCallCheck(this, InterpolationBinding); + + if (targetProperty === 'style') { + _aureliaLogging.getLogger('templating-binding').info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); + } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { + throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); + } + + this.observerLocator = observerLocator; + this.parts = parts; + this.targetProperty = observerLocator.getObserver(target, targetProperty); + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + InterpolationBinding.prototype.interpolate = function interpolate() { + if (this.isBound) { + var value = ''; + var parts = this.parts; + for (var i = 0, ii = parts.length; i < ii; i++) { + value += i % 2 === 0 ? parts[i] : this['childBinding' + i].value; + } + this.targetProperty.setValue(value); + } + }; + + InterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.source = source; + + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var binding = new ChildInterpolationBinding(this, this.observerLocator, parts[i], this.mode, this.lookupFunctions); + binding.bind(source); + this['childBinding' + i] = binding; + } + + this.isBound = true; + this.interpolate(); + }; + + InterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + this.source = null; + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var _name = 'childBinding' + i; + this[_name].unbind(); + } + }; + + return InterpolationBinding; + })(); + + exports.InterpolationBinding = InterpolationBinding; + + var ChildInterpolationBinding = (function () { + function ChildInterpolationBinding(parent, observerLocator, sourceExpression, mode, lookupFunctions) { + _classCallCheck(this, _ChildInterpolationBinding); + + this.parent = parent; + this.observerLocator = observerLocator; + this.sourceExpression = sourceExpression; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + ChildInterpolationBinding.prototype.updateTarget = function updateTarget(value) { + value = value === null || value === undefined ? '' : value.toString(); + if (value !== this.value) { + this.value = value; + this.parent.interpolate(); + } + }; + + ChildInterpolationBinding.prototype.call = function call() { + if (!this.isBound) { + return; + } + + var value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); + this.updateTarget(value); + + this._version++; + this.sourceExpression.connect(this, this.source); + if (value instanceof Array) { + this.observeArray(value); + } + this.unobserve(false); + }; + + ChildInterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.isBound = true; + this.source = source; + + var sourceExpression = this.sourceExpression; + if (sourceExpression.bind) { + sourceExpression.bind(this, source, this.lookupFunctions); + } + + var value = sourceExpression.evaluate(source, this.lookupFunctions); + this.updateTarget(value); + + if (this.mode === _aureliaBinding.bindingMode.oneWay) { + sourceExpression.connect(this, source); + if (value instanceof Array) { + this.observeArray(value); + } + } + }; + + ChildInterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + var sourceExpression = this.sourceExpression; + if (sourceExpression.unbind) { + sourceExpression.unbind(this, this.source); + } + this.source = null; + this.unobserve(true); + }; + + var _ChildInterpolationBinding = ChildInterpolationBinding; + ChildInterpolationBinding = _aureliaBinding.connectable()(ChildInterpolationBinding) || ChildInterpolationBinding; + return ChildInterpolationBinding; + })(); + + exports.ChildInterpolationBinding = ChildInterpolationBinding; + var SyntaxInterpreter = (function () { SyntaxInterpreter.inject = function inject() { return [_aureliaBinding.Parser, _aureliaBinding.ObserverLocator, _aureliaBinding.EventManager]; @@ -30,16 +199,8 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], }; SyntaxInterpreter.prototype.handleUnknownCommand = function handleUnknownCommand(resources, element, info, existingInstruction) { - var attrName = info.attrName; - var command = info.command; - var instruction = this.options(resources, element, info, existingInstruction); - - instruction.alteredAttr = true; - instruction.attrName = 'global-behavior'; - instruction.attributes.aureliaAttrName = attrName; - instruction.attributes.aureliaCommand = command; - - return instruction; + _aureliaLogging.getLogger('templating-binding').warn('Unknown binding command.', info); + return existingInstruction; }; SyntaxInterpreter.prototype.determineDefaultBindingMode = function determineDefaultBindingMode(element, attrName) { @@ -61,23 +222,23 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], SyntaxInterpreter.prototype.bind = function bind(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.lookupFunctions); return instruction; }; SyntaxInterpreter.prototype.trigger = function trigger(resources, element, info) { - return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true); + return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.delegate = function delegate(resources, element, info) { - return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true); + return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.call = function call(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.lookupFunctions); return instruction; }; @@ -150,7 +311,7 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], instruction.attributes.local = parts[0]; } - instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -158,7 +319,7 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], SyntaxInterpreter.prototype['two-way'] = function twoWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.twoWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.twoWay, resources.lookupFunctions); return instruction; }; @@ -166,7 +327,7 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], SyntaxInterpreter.prototype['one-way'] = function oneWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -174,7 +335,7 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], SyntaxInterpreter.prototype['one-time'] = function oneTime(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneTime, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneTime, resources.lookupFunctions); return instruction; }; @@ -185,7 +346,6 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], exports.SyntaxInterpreter = SyntaxInterpreter; var info = {}; - var logger = _aureliaLogging.getLogger('templating-binding'); var TemplatingBindingLanguage = (function (_BindingLanguage) { _inherits(TemplatingBindingLanguage, _BindingLanguage); @@ -349,7 +509,7 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], parts[partIndex] = attrValue.substr(pos); - return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction, attrName); + return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions, attrName); }; return TemplatingBindingLanguage; @@ -357,108 +517,8 @@ define(['exports', 'aurelia-logging', 'aurelia-binding', 'aurelia-templating'], exports.TemplatingBindingLanguage = TemplatingBindingLanguage; - var InterpolationBindingExpression = (function () { - function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, valueConverterLookupFunction, attribute) { - _classCallCheck(this, InterpolationBindingExpression); - - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.parts = parts; - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - this.attribute = this.attrToRemove = attribute; - this.discrete = false; - } - - InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { - return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.valueConverterLookupFunction); - }; - - return InterpolationBindingExpression; - })(); - - exports.InterpolationBindingExpression = InterpolationBindingExpression; - - var InterpolationBinding = (function () { - function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, valueConverterLookupFunction) { - _classCallCheck(this, _InterpolationBinding); - - if (targetProperty === 'style') { - logger.info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); - } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { - throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); - } - - this.observerLocator = observerLocator; - this.parts = parts; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - } - - InterpolationBinding.prototype.bind = function bind(source) { - if (this.source !== undefined) { - this.unbind(); - } - this.source = source; - this.interpolate(this.mode === _aureliaBinding.bindingMode.oneWay, true); - }; - - InterpolationBinding.prototype.call = function call() { - if (this.source !== undefined) { - this._version++; - this.interpolate(this.mode === _aureliaBinding.bindingMode.oneWay, false); - } - }; - - InterpolationBinding.prototype.interpolate = function interpolate(connect, initial) { - var value = ''; - var parts = this.parts; - var source = this.source; - var valueConverterLookupFunction = this.valueConverterLookupFunction; - - for (var i = 0, ii = parts.length; i < ii; ++i) { - if (i % 2 === 0) { - value += parts[i]; - } else { - var part = parts[i].evaluate(source, valueConverterLookupFunction); - value += part === undefined || part === null ? '' : part.toString(); - if (connect) { - parts[i].connect(this, source); - if (part instanceof Array) { - this.observeArray(part); - } - } - } - } - this.targetProperty.setValue(value); - if (!initial) { - this.unobserve(false); - } - }; - - InterpolationBinding.prototype.unbind = function unbind() { - this.source = undefined; - this.unobserve(true); - }; - - var _InterpolationBinding = InterpolationBinding; - InterpolationBinding = _aureliaBinding.connectable()(InterpolationBinding) || InterpolationBinding; - return InterpolationBinding; - })(); - function configure(config) { - var instance = undefined; - var getInstance = function getInstance(c) { - return instance || (instance = c.invoke(TemplatingBindingLanguage)); - }; - - if (config.container.hasHandler(TemplatingBindingLanguage)) { - instance = config.container.get(TemplatingBindingLanguage); - } else { - config.container.registerHandler(TemplatingBindingLanguage, getInstance); - } - - config.container.registerHandler(_aureliaTemplating.BindingLanguage, getInstance); + config.container.registerSingleton(_aureliaTemplating.BindingLanguage, TemplatingBindingLanguage); + config.container.registerAlias(_aureliaTemplating.BindingLanguage, TemplatingBindingLanguage); } }); \ No newline at end of file diff --git a/dist/aurelia-templating-binding.d.ts b/dist/aurelia-templating-binding.d.ts index 6bf2813..4a348ef 100644 --- a/dist/aurelia-templating-binding.d.ts +++ b/dist/aurelia-templating-binding.d.ts @@ -1,7 +1,24 @@ declare module 'aurelia-templating-binding' { import * as LogManager from 'aurelia-logging'; - import { Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable } from 'aurelia-binding'; + import { bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression } from 'aurelia-binding'; import { BehaviorInstruction, BindingLanguage } from 'aurelia-templating'; + export class InterpolationBindingExpression { + constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, lookupFunctions: any, attribute: any); + createBinding(target: any): any; + } + export class InterpolationBinding { + constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, lookupFunctions: any); + interpolate(): any; + bind(source: any): any; + unbind(): any; + } + export class ChildInterpolationBinding { + constructor(parent: any, observerLocator: any, sourceExpression: any, mode: any, lookupFunctions: any); + updateTarget(value: any): any; + call(): any; + bind(source: any): any; + unbind(): any; + } /*eslint dot-notation:0*/ export class SyntaxInterpreter { @@ -28,16 +45,5 @@ declare module 'aurelia-templating-binding' { parseText(resources: any, value: any): any; parseContent(resources: any, attrName: any, attrValue: any): any; } - export class InterpolationBindingExpression { - constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, valueConverterLookupFunction: any, attribute: any); - createBinding(target: any): any; - } - class InterpolationBinding { - constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, valueConverterLookupFunction: any); - bind(source: any): any; - call(): any; - interpolate(connect: any, initial: any): any; - unbind(): any; - } export function configure(config: any): any; } \ No newline at end of file diff --git a/dist/aurelia-templating-binding.js b/dist/aurelia-templating-binding.js index be0232f..a0dbd4e 100644 --- a/dist/aurelia-templating-binding.js +++ b/dist/aurelia-templating-binding.js @@ -1,7 +1,167 @@ import * as LogManager from 'aurelia-logging'; -import {Parser,ObserverLocator,EventManager,ListenerExpression,BindingExpression,CallExpression,bindingMode,NameExpression,connectable} from 'aurelia-binding'; +import {bindingMode,connectable,Parser,ObserverLocator,EventManager,ListenerExpression,BindingExpression,CallExpression,NameExpression} from 'aurelia-binding'; import {BehaviorInstruction,BindingLanguage} from 'aurelia-templating'; +export class InterpolationBindingExpression { + constructor(observerLocator, targetProperty, parts, + mode, lookupFunctions, attribute) { + this.observerLocator = observerLocator; + this.targetProperty = targetProperty; + this.parts = parts; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + this.attribute = this.attrToRemove = attribute; + this.discrete = false; + } + + createBinding(target) { + return new InterpolationBinding( + this.observerLocator, + this.parts, + target, + this.targetProperty, + this.mode, + this.lookupFunctions + ); + } +} + +export class InterpolationBinding { + constructor(observerLocator, parts, target, targetProperty, mode, lookupFunctions) { + if (targetProperty === 'style') { + LogManager.getLogger('templating-binding') + .info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); + } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { + throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); + } + + this.observerLocator = observerLocator; + this.parts = parts; + this.targetProperty = observerLocator.getObserver(target, targetProperty); + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + interpolate() { + if (this.isBound) { + let value = ''; + let parts = this.parts; + for (let i = 0, ii = parts.length; i < ii; i++) { + value += (i % 2 === 0 ? parts[i] : this[`childBinding${i}`].value); + } + this.targetProperty.setValue(value); + } + } + + bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.source = source; + + let parts = this.parts; + for (let i = 1, ii = parts.length; i < ii; i += 2) { + let binding = new ChildInterpolationBinding(this, this.observerLocator, parts[i], this.mode, this.lookupFunctions); + binding.bind(source); + this[`childBinding${i}`] = binding; + } + + this.isBound = true; + this.interpolate(); + } + + unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + this.source = null; + let parts = this.parts; + for (let i = 1, ii = parts.length; i < ii; i += 2) { + let name = `childBinding${i}`; + this[name].unbind(); + } + } +} + + +@connectable() +export class ChildInterpolationBinding { + constructor(parent, observerLocator, sourceExpression, mode, lookupFunctions) { + this.parent = parent; + this.observerLocator = observerLocator; + this.sourceExpression = sourceExpression; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + updateTarget(value) { + value = value === null || value === undefined ? '' : value.toString(); + if (value !== this.value) { + this.value = value; + this.parent.interpolate(); + } + } + + call() { + if (!this.isBound) { + return; + } + + let value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); + this.updateTarget(value); + + this._version++; + this.sourceExpression.connect(this, this.source); + if (value instanceof Array) { + this.observeArray(value); + } + this.unobserve(false); + } + + bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.isBound = true; + this.source = source; + + let sourceExpression = this.sourceExpression; + if (sourceExpression.bind) { + sourceExpression.bind(this, source, this.lookupFunctions); + } + + let value = sourceExpression.evaluate(source, this.lookupFunctions); + this.updateTarget(value); + + if (this.mode === bindingMode.oneWay) { + sourceExpression.connect(this, source); + if (value instanceof Array) { + this.observeArray(value); + } + } + } + + unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + let sourceExpression = this.sourceExpression; + if (sourceExpression.unbind) { + sourceExpression.unbind(this, this.source); + } + this.source = null; + this.unobserve(true); + } +} + /*eslint dot-notation:0*/ export class SyntaxInterpreter { static inject() { return [Parser, ObserverLocator, EventManager]; } @@ -20,16 +180,8 @@ export class SyntaxInterpreter { } handleUnknownCommand(resources, element, info, existingInstruction) { - let attrName = info.attrName; - let command = info.command; - let instruction = this.options(resources, element, info, existingInstruction); - - instruction.alteredAttr = true; - instruction.attrName = 'global-behavior'; - instruction.attributes.aureliaAttrName = attrName; - instruction.attributes.aureliaCommand = command; - - return instruction; + LogManager.getLogger('templating-binding').warn('Unknown binding command.', info); + return existingInstruction; } determineDefaultBindingMode(element, attrName) { @@ -56,7 +208,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -68,7 +220,8 @@ export class SyntaxInterpreter { info.attrName, this.parser.parse(info.attrValue), false, - true + true, + resources.lookupFunctions ); } @@ -78,7 +231,8 @@ export class SyntaxInterpreter { info.attrName, this.parser.parse(info.attrValue), true, - true + true, + resources.lookupFunctions ); } @@ -89,7 +243,7 @@ export class SyntaxInterpreter { this.observerLocator, info.attrName, this.parser.parse(info.attrValue), - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -168,7 +322,7 @@ export class SyntaxInterpreter { 'items', this.parser.parse(parts[1]), bindingMode.oneWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -182,7 +336,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.twoWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -196,7 +350,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -210,7 +364,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneTime, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -218,7 +372,6 @@ export class SyntaxInterpreter { } let info = {}; -let logger = LogManager.getLogger('templating-binding'); export class TemplatingBindingLanguage extends BindingLanguage { static inject() { return [Parser, ObserverLocator, SyntaxInterpreter]; } @@ -390,110 +543,13 @@ export class TemplatingBindingLanguage extends BindingLanguage { this.attributeMap[attrName] || attrName, parts, bindingMode.oneWay, - resources.valueConverterLookupFunction, + resources.lookupFunctions, attrName ); } } -export class InterpolationBindingExpression { - constructor(observerLocator, targetProperty, parts, - mode, valueConverterLookupFunction, attribute) { - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.parts = parts; - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - this.attribute = this.attrToRemove = attribute; - this.discrete = false; - } - - createBinding(target) { - return new InterpolationBinding( - this.observerLocator, - this.parts, - target, - this.targetProperty, - this.mode, - this.valueConverterLookupFunction - ); - } -} - -@connectable() -class InterpolationBinding { - constructor(observerLocator, parts, target, targetProperty, mode, valueConverterLookupFunction) { - if (targetProperty === 'style') { - logger.info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); - } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { - throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); - } - - this.observerLocator = observerLocator; - this.parts = parts; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - } - - bind(source) { - if (this.source !== undefined) { - this.unbind(); - } - this.source = source; - this.interpolate(this.mode === bindingMode.oneWay, true); - } - - call() { - if (this.source !== undefined) { - this._version++; - this.interpolate(this.mode === bindingMode.oneWay, false); - } - } - - interpolate(connect, initial) { - let value = ''; - let parts = this.parts; - let source = this.source; - let valueConverterLookupFunction = this.valueConverterLookupFunction; - - for (let i = 0, ii = parts.length; i < ii; ++i) { - if (i % 2 === 0) { - value += parts[i]; - } else { - let part = parts[i].evaluate(source, valueConverterLookupFunction); - value += part === undefined || part === null ? '' : part.toString(); - if (connect) { - parts[i].connect(this, source); - if (part instanceof Array) { - this.observeArray(part); - } - } - } - } - this.targetProperty.setValue(value); - if (!initial) { - this.unobserve(false); - } - } - - unbind() { - this.source = undefined; - this.unobserve(true); - } -} - export function configure(config) { - let instance; - let getInstance = function(c) { - return instance || (instance = c.invoke(TemplatingBindingLanguage)); - }; - - if (config.container.hasHandler(TemplatingBindingLanguage)) { - instance = config.container.get(TemplatingBindingLanguage); - } else { - config.container.registerHandler(TemplatingBindingLanguage, getInstance); - } - - config.container.registerHandler(BindingLanguage, getInstance); + config.container.registerSingleton(BindingLanguage, TemplatingBindingLanguage); + config.container.registerAlias(BindingLanguage, TemplatingBindingLanguage); } diff --git a/dist/commonjs/aurelia-templating-binding.d.ts b/dist/commonjs/aurelia-templating-binding.d.ts index 6bf2813..4a348ef 100644 --- a/dist/commonjs/aurelia-templating-binding.d.ts +++ b/dist/commonjs/aurelia-templating-binding.d.ts @@ -1,7 +1,24 @@ declare module 'aurelia-templating-binding' { import * as LogManager from 'aurelia-logging'; - import { Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable } from 'aurelia-binding'; + import { bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression } from 'aurelia-binding'; import { BehaviorInstruction, BindingLanguage } from 'aurelia-templating'; + export class InterpolationBindingExpression { + constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, lookupFunctions: any, attribute: any); + createBinding(target: any): any; + } + export class InterpolationBinding { + constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, lookupFunctions: any); + interpolate(): any; + bind(source: any): any; + unbind(): any; + } + export class ChildInterpolationBinding { + constructor(parent: any, observerLocator: any, sourceExpression: any, mode: any, lookupFunctions: any); + updateTarget(value: any): any; + call(): any; + bind(source: any): any; + unbind(): any; + } /*eslint dot-notation:0*/ export class SyntaxInterpreter { @@ -28,16 +45,5 @@ declare module 'aurelia-templating-binding' { parseText(resources: any, value: any): any; parseContent(resources: any, attrName: any, attrValue: any): any; } - export class InterpolationBindingExpression { - constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, valueConverterLookupFunction: any, attribute: any); - createBinding(target: any): any; - } - class InterpolationBinding { - constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, valueConverterLookupFunction: any); - bind(source: any): any; - call(): any; - interpolate(connect: any, initial: any): any; - unbind(): any; - } export function configure(config: any): any; } \ No newline at end of file diff --git a/dist/commonjs/aurelia-templating-binding.js b/dist/commonjs/aurelia-templating-binding.js index 52ca6e1..0f38342 100644 --- a/dist/commonjs/aurelia-templating-binding.js +++ b/dist/commonjs/aurelia-templating-binding.js @@ -17,6 +17,175 @@ var _aureliaBinding = require('aurelia-binding'); var _aureliaTemplating = require('aurelia-templating'); +var InterpolationBindingExpression = (function () { + function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, lookupFunctions, attribute) { + _classCallCheck(this, InterpolationBindingExpression); + + this.observerLocator = observerLocator; + this.targetProperty = targetProperty; + this.parts = parts; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + this.attribute = this.attrToRemove = attribute; + this.discrete = false; + } + + InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { + return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.lookupFunctions); + }; + + return InterpolationBindingExpression; +})(); + +exports.InterpolationBindingExpression = InterpolationBindingExpression; + +var InterpolationBinding = (function () { + function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, lookupFunctions) { + _classCallCheck(this, InterpolationBinding); + + if (targetProperty === 'style') { + LogManager.getLogger('templating-binding').info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); + } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { + throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); + } + + this.observerLocator = observerLocator; + this.parts = parts; + this.targetProperty = observerLocator.getObserver(target, targetProperty); + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + InterpolationBinding.prototype.interpolate = function interpolate() { + if (this.isBound) { + var value = ''; + var parts = this.parts; + for (var i = 0, ii = parts.length; i < ii; i++) { + value += i % 2 === 0 ? parts[i] : this['childBinding' + i].value; + } + this.targetProperty.setValue(value); + } + }; + + InterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.source = source; + + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var binding = new ChildInterpolationBinding(this, this.observerLocator, parts[i], this.mode, this.lookupFunctions); + binding.bind(source); + this['childBinding' + i] = binding; + } + + this.isBound = true; + this.interpolate(); + }; + + InterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + this.source = null; + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var _name = 'childBinding' + i; + this[_name].unbind(); + } + }; + + return InterpolationBinding; +})(); + +exports.InterpolationBinding = InterpolationBinding; + +var ChildInterpolationBinding = (function () { + function ChildInterpolationBinding(parent, observerLocator, sourceExpression, mode, lookupFunctions) { + _classCallCheck(this, _ChildInterpolationBinding); + + this.parent = parent; + this.observerLocator = observerLocator; + this.sourceExpression = sourceExpression; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + ChildInterpolationBinding.prototype.updateTarget = function updateTarget(value) { + value = value === null || value === undefined ? '' : value.toString(); + if (value !== this.value) { + this.value = value; + this.parent.interpolate(); + } + }; + + ChildInterpolationBinding.prototype.call = function call() { + if (!this.isBound) { + return; + } + + var value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); + this.updateTarget(value); + + this._version++; + this.sourceExpression.connect(this, this.source); + if (value instanceof Array) { + this.observeArray(value); + } + this.unobserve(false); + }; + + ChildInterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.isBound = true; + this.source = source; + + var sourceExpression = this.sourceExpression; + if (sourceExpression.bind) { + sourceExpression.bind(this, source, this.lookupFunctions); + } + + var value = sourceExpression.evaluate(source, this.lookupFunctions); + this.updateTarget(value); + + if (this.mode === _aureliaBinding.bindingMode.oneWay) { + sourceExpression.connect(this, source); + if (value instanceof Array) { + this.observeArray(value); + } + } + }; + + ChildInterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + var sourceExpression = this.sourceExpression; + if (sourceExpression.unbind) { + sourceExpression.unbind(this, this.source); + } + this.source = null; + this.unobserve(true); + }; + + var _ChildInterpolationBinding = ChildInterpolationBinding; + ChildInterpolationBinding = _aureliaBinding.connectable()(ChildInterpolationBinding) || ChildInterpolationBinding; + return ChildInterpolationBinding; +})(); + +exports.ChildInterpolationBinding = ChildInterpolationBinding; + var SyntaxInterpreter = (function () { SyntaxInterpreter.inject = function inject() { return [_aureliaBinding.Parser, _aureliaBinding.ObserverLocator, _aureliaBinding.EventManager]; @@ -39,16 +208,8 @@ var SyntaxInterpreter = (function () { }; SyntaxInterpreter.prototype.handleUnknownCommand = function handleUnknownCommand(resources, element, info, existingInstruction) { - var attrName = info.attrName; - var command = info.command; - var instruction = this.options(resources, element, info, existingInstruction); - - instruction.alteredAttr = true; - instruction.attrName = 'global-behavior'; - instruction.attributes.aureliaAttrName = attrName; - instruction.attributes.aureliaCommand = command; - - return instruction; + LogManager.getLogger('templating-binding').warn('Unknown binding command.', info); + return existingInstruction; }; SyntaxInterpreter.prototype.determineDefaultBindingMode = function determineDefaultBindingMode(element, attrName) { @@ -70,23 +231,23 @@ var SyntaxInterpreter = (function () { SyntaxInterpreter.prototype.bind = function bind(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.lookupFunctions); return instruction; }; SyntaxInterpreter.prototype.trigger = function trigger(resources, element, info) { - return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true); + return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.delegate = function delegate(resources, element, info) { - return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true); + return new _aureliaBinding.ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.call = function call(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.lookupFunctions); return instruction; }; @@ -159,7 +320,7 @@ var SyntaxInterpreter = (function () { instruction.attributes.local = parts[0]; } - instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -167,7 +328,7 @@ var SyntaxInterpreter = (function () { SyntaxInterpreter.prototype['two-way'] = function twoWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.twoWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.twoWay, resources.lookupFunctions); return instruction; }; @@ -175,7 +336,7 @@ var SyntaxInterpreter = (function () { SyntaxInterpreter.prototype['one-way'] = function oneWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -183,7 +344,7 @@ var SyntaxInterpreter = (function () { SyntaxInterpreter.prototype['one-time'] = function oneTime(resources, element, info, existingInstruction) { var instruction = existingInstruction || _aureliaTemplating.BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneTime, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new _aureliaBinding.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _aureliaBinding.bindingMode.oneTime, resources.lookupFunctions); return instruction; }; @@ -194,7 +355,6 @@ var SyntaxInterpreter = (function () { exports.SyntaxInterpreter = SyntaxInterpreter; var info = {}; -var logger = LogManager.getLogger('templating-binding'); var TemplatingBindingLanguage = (function (_BindingLanguage) { _inherits(TemplatingBindingLanguage, _BindingLanguage); @@ -358,7 +518,7 @@ var TemplatingBindingLanguage = (function (_BindingLanguage) { parts[partIndex] = attrValue.substr(pos); - return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction, attrName); + return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _aureliaBinding.bindingMode.oneWay, resources.lookupFunctions, attrName); }; return TemplatingBindingLanguage; @@ -366,107 +526,7 @@ var TemplatingBindingLanguage = (function (_BindingLanguage) { exports.TemplatingBindingLanguage = TemplatingBindingLanguage; -var InterpolationBindingExpression = (function () { - function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, valueConverterLookupFunction, attribute) { - _classCallCheck(this, InterpolationBindingExpression); - - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.parts = parts; - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - this.attribute = this.attrToRemove = attribute; - this.discrete = false; - } - - InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { - return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.valueConverterLookupFunction); - }; - - return InterpolationBindingExpression; -})(); - -exports.InterpolationBindingExpression = InterpolationBindingExpression; - -var InterpolationBinding = (function () { - function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, valueConverterLookupFunction) { - _classCallCheck(this, _InterpolationBinding); - - if (targetProperty === 'style') { - logger.info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); - } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { - throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); - } - - this.observerLocator = observerLocator; - this.parts = parts; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - } - - InterpolationBinding.prototype.bind = function bind(source) { - if (this.source !== undefined) { - this.unbind(); - } - this.source = source; - this.interpolate(this.mode === _aureliaBinding.bindingMode.oneWay, true); - }; - - InterpolationBinding.prototype.call = function call() { - if (this.source !== undefined) { - this._version++; - this.interpolate(this.mode === _aureliaBinding.bindingMode.oneWay, false); - } - }; - - InterpolationBinding.prototype.interpolate = function interpolate(connect, initial) { - var value = ''; - var parts = this.parts; - var source = this.source; - var valueConverterLookupFunction = this.valueConverterLookupFunction; - - for (var i = 0, ii = parts.length; i < ii; ++i) { - if (i % 2 === 0) { - value += parts[i]; - } else { - var part = parts[i].evaluate(source, valueConverterLookupFunction); - value += part === undefined || part === null ? '' : part.toString(); - if (connect) { - parts[i].connect(this, source); - if (part instanceof Array) { - this.observeArray(part); - } - } - } - } - this.targetProperty.setValue(value); - if (!initial) { - this.unobserve(false); - } - }; - - InterpolationBinding.prototype.unbind = function unbind() { - this.source = undefined; - this.unobserve(true); - }; - - var _InterpolationBinding = InterpolationBinding; - InterpolationBinding = _aureliaBinding.connectable()(InterpolationBinding) || InterpolationBinding; - return InterpolationBinding; -})(); - function configure(config) { - var instance = undefined; - var getInstance = function getInstance(c) { - return instance || (instance = c.invoke(TemplatingBindingLanguage)); - }; - - if (config.container.hasHandler(TemplatingBindingLanguage)) { - instance = config.container.get(TemplatingBindingLanguage); - } else { - config.container.registerHandler(TemplatingBindingLanguage, getInstance); - } - - config.container.registerHandler(_aureliaTemplating.BindingLanguage, getInstance); + config.container.registerSingleton(_aureliaTemplating.BindingLanguage, TemplatingBindingLanguage); + config.container.registerAlias(_aureliaTemplating.BindingLanguage, TemplatingBindingLanguage); } \ No newline at end of file diff --git a/dist/es6/aurelia-templating-binding.d.ts b/dist/es6/aurelia-templating-binding.d.ts index 6bf2813..4a348ef 100644 --- a/dist/es6/aurelia-templating-binding.d.ts +++ b/dist/es6/aurelia-templating-binding.d.ts @@ -1,7 +1,24 @@ declare module 'aurelia-templating-binding' { import * as LogManager from 'aurelia-logging'; - import { Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable } from 'aurelia-binding'; + import { bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression } from 'aurelia-binding'; import { BehaviorInstruction, BindingLanguage } from 'aurelia-templating'; + export class InterpolationBindingExpression { + constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, lookupFunctions: any, attribute: any); + createBinding(target: any): any; + } + export class InterpolationBinding { + constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, lookupFunctions: any); + interpolate(): any; + bind(source: any): any; + unbind(): any; + } + export class ChildInterpolationBinding { + constructor(parent: any, observerLocator: any, sourceExpression: any, mode: any, lookupFunctions: any); + updateTarget(value: any): any; + call(): any; + bind(source: any): any; + unbind(): any; + } /*eslint dot-notation:0*/ export class SyntaxInterpreter { @@ -28,16 +45,5 @@ declare module 'aurelia-templating-binding' { parseText(resources: any, value: any): any; parseContent(resources: any, attrName: any, attrValue: any): any; } - export class InterpolationBindingExpression { - constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, valueConverterLookupFunction: any, attribute: any); - createBinding(target: any): any; - } - class InterpolationBinding { - constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, valueConverterLookupFunction: any); - bind(source: any): any; - call(): any; - interpolate(connect: any, initial: any): any; - unbind(): any; - } export function configure(config: any): any; } \ No newline at end of file diff --git a/dist/es6/aurelia-templating-binding.js b/dist/es6/aurelia-templating-binding.js index be0232f..a0dbd4e 100644 --- a/dist/es6/aurelia-templating-binding.js +++ b/dist/es6/aurelia-templating-binding.js @@ -1,7 +1,167 @@ import * as LogManager from 'aurelia-logging'; -import {Parser,ObserverLocator,EventManager,ListenerExpression,BindingExpression,CallExpression,bindingMode,NameExpression,connectable} from 'aurelia-binding'; +import {bindingMode,connectable,Parser,ObserverLocator,EventManager,ListenerExpression,BindingExpression,CallExpression,NameExpression} from 'aurelia-binding'; import {BehaviorInstruction,BindingLanguage} from 'aurelia-templating'; +export class InterpolationBindingExpression { + constructor(observerLocator, targetProperty, parts, + mode, lookupFunctions, attribute) { + this.observerLocator = observerLocator; + this.targetProperty = targetProperty; + this.parts = parts; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + this.attribute = this.attrToRemove = attribute; + this.discrete = false; + } + + createBinding(target) { + return new InterpolationBinding( + this.observerLocator, + this.parts, + target, + this.targetProperty, + this.mode, + this.lookupFunctions + ); + } +} + +export class InterpolationBinding { + constructor(observerLocator, parts, target, targetProperty, mode, lookupFunctions) { + if (targetProperty === 'style') { + LogManager.getLogger('templating-binding') + .info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); + } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { + throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); + } + + this.observerLocator = observerLocator; + this.parts = parts; + this.targetProperty = observerLocator.getObserver(target, targetProperty); + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + interpolate() { + if (this.isBound) { + let value = ''; + let parts = this.parts; + for (let i = 0, ii = parts.length; i < ii; i++) { + value += (i % 2 === 0 ? parts[i] : this[`childBinding${i}`].value); + } + this.targetProperty.setValue(value); + } + } + + bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.source = source; + + let parts = this.parts; + for (let i = 1, ii = parts.length; i < ii; i += 2) { + let binding = new ChildInterpolationBinding(this, this.observerLocator, parts[i], this.mode, this.lookupFunctions); + binding.bind(source); + this[`childBinding${i}`] = binding; + } + + this.isBound = true; + this.interpolate(); + } + + unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + this.source = null; + let parts = this.parts; + for (let i = 1, ii = parts.length; i < ii; i += 2) { + let name = `childBinding${i}`; + this[name].unbind(); + } + } +} + + +@connectable() +export class ChildInterpolationBinding { + constructor(parent, observerLocator, sourceExpression, mode, lookupFunctions) { + this.parent = parent; + this.observerLocator = observerLocator; + this.sourceExpression = sourceExpression; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + updateTarget(value) { + value = value === null || value === undefined ? '' : value.toString(); + if (value !== this.value) { + this.value = value; + this.parent.interpolate(); + } + } + + call() { + if (!this.isBound) { + return; + } + + let value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); + this.updateTarget(value); + + this._version++; + this.sourceExpression.connect(this, this.source); + if (value instanceof Array) { + this.observeArray(value); + } + this.unobserve(false); + } + + bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.isBound = true; + this.source = source; + + let sourceExpression = this.sourceExpression; + if (sourceExpression.bind) { + sourceExpression.bind(this, source, this.lookupFunctions); + } + + let value = sourceExpression.evaluate(source, this.lookupFunctions); + this.updateTarget(value); + + if (this.mode === bindingMode.oneWay) { + sourceExpression.connect(this, source); + if (value instanceof Array) { + this.observeArray(value); + } + } + } + + unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + let sourceExpression = this.sourceExpression; + if (sourceExpression.unbind) { + sourceExpression.unbind(this, this.source); + } + this.source = null; + this.unobserve(true); + } +} + /*eslint dot-notation:0*/ export class SyntaxInterpreter { static inject() { return [Parser, ObserverLocator, EventManager]; } @@ -20,16 +180,8 @@ export class SyntaxInterpreter { } handleUnknownCommand(resources, element, info, existingInstruction) { - let attrName = info.attrName; - let command = info.command; - let instruction = this.options(resources, element, info, existingInstruction); - - instruction.alteredAttr = true; - instruction.attrName = 'global-behavior'; - instruction.attributes.aureliaAttrName = attrName; - instruction.attributes.aureliaCommand = command; - - return instruction; + LogManager.getLogger('templating-binding').warn('Unknown binding command.', info); + return existingInstruction; } determineDefaultBindingMode(element, attrName) { @@ -56,7 +208,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -68,7 +220,8 @@ export class SyntaxInterpreter { info.attrName, this.parser.parse(info.attrValue), false, - true + true, + resources.lookupFunctions ); } @@ -78,7 +231,8 @@ export class SyntaxInterpreter { info.attrName, this.parser.parse(info.attrValue), true, - true + true, + resources.lookupFunctions ); } @@ -89,7 +243,7 @@ export class SyntaxInterpreter { this.observerLocator, info.attrName, this.parser.parse(info.attrValue), - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -168,7 +322,7 @@ export class SyntaxInterpreter { 'items', this.parser.parse(parts[1]), bindingMode.oneWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -182,7 +336,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.twoWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -196,7 +350,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneWay, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -210,7 +364,7 @@ export class SyntaxInterpreter { this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneTime, - resources.valueConverterLookupFunction + resources.lookupFunctions ); return instruction; @@ -218,7 +372,6 @@ export class SyntaxInterpreter { } let info = {}; -let logger = LogManager.getLogger('templating-binding'); export class TemplatingBindingLanguage extends BindingLanguage { static inject() { return [Parser, ObserverLocator, SyntaxInterpreter]; } @@ -390,110 +543,13 @@ export class TemplatingBindingLanguage extends BindingLanguage { this.attributeMap[attrName] || attrName, parts, bindingMode.oneWay, - resources.valueConverterLookupFunction, + resources.lookupFunctions, attrName ); } } -export class InterpolationBindingExpression { - constructor(observerLocator, targetProperty, parts, - mode, valueConverterLookupFunction, attribute) { - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.parts = parts; - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - this.attribute = this.attrToRemove = attribute; - this.discrete = false; - } - - createBinding(target) { - return new InterpolationBinding( - this.observerLocator, - this.parts, - target, - this.targetProperty, - this.mode, - this.valueConverterLookupFunction - ); - } -} - -@connectable() -class InterpolationBinding { - constructor(observerLocator, parts, target, targetProperty, mode, valueConverterLookupFunction) { - if (targetProperty === 'style') { - logger.info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); - } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { - throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); - } - - this.observerLocator = observerLocator; - this.parts = parts; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - } - - bind(source) { - if (this.source !== undefined) { - this.unbind(); - } - this.source = source; - this.interpolate(this.mode === bindingMode.oneWay, true); - } - - call() { - if (this.source !== undefined) { - this._version++; - this.interpolate(this.mode === bindingMode.oneWay, false); - } - } - - interpolate(connect, initial) { - let value = ''; - let parts = this.parts; - let source = this.source; - let valueConverterLookupFunction = this.valueConverterLookupFunction; - - for (let i = 0, ii = parts.length; i < ii; ++i) { - if (i % 2 === 0) { - value += parts[i]; - } else { - let part = parts[i].evaluate(source, valueConverterLookupFunction); - value += part === undefined || part === null ? '' : part.toString(); - if (connect) { - parts[i].connect(this, source); - if (part instanceof Array) { - this.observeArray(part); - } - } - } - } - this.targetProperty.setValue(value); - if (!initial) { - this.unobserve(false); - } - } - - unbind() { - this.source = undefined; - this.unobserve(true); - } -} - export function configure(config) { - let instance; - let getInstance = function(c) { - return instance || (instance = c.invoke(TemplatingBindingLanguage)); - }; - - if (config.container.hasHandler(TemplatingBindingLanguage)) { - instance = config.container.get(TemplatingBindingLanguage); - } else { - config.container.registerHandler(TemplatingBindingLanguage, getInstance); - } - - config.container.registerHandler(BindingLanguage, getInstance); + config.container.registerSingleton(BindingLanguage, TemplatingBindingLanguage); + config.container.registerAlias(BindingLanguage, TemplatingBindingLanguage); } diff --git a/dist/system/aurelia-templating-binding.d.ts b/dist/system/aurelia-templating-binding.d.ts index 6bf2813..4a348ef 100644 --- a/dist/system/aurelia-templating-binding.d.ts +++ b/dist/system/aurelia-templating-binding.d.ts @@ -1,7 +1,24 @@ declare module 'aurelia-templating-binding' { import * as LogManager from 'aurelia-logging'; - import { Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable } from 'aurelia-binding'; + import { bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression } from 'aurelia-binding'; import { BehaviorInstruction, BindingLanguage } from 'aurelia-templating'; + export class InterpolationBindingExpression { + constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, lookupFunctions: any, attribute: any); + createBinding(target: any): any; + } + export class InterpolationBinding { + constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, lookupFunctions: any); + interpolate(): any; + bind(source: any): any; + unbind(): any; + } + export class ChildInterpolationBinding { + constructor(parent: any, observerLocator: any, sourceExpression: any, mode: any, lookupFunctions: any); + updateTarget(value: any): any; + call(): any; + bind(source: any): any; + unbind(): any; + } /*eslint dot-notation:0*/ export class SyntaxInterpreter { @@ -28,16 +45,5 @@ declare module 'aurelia-templating-binding' { parseText(resources: any, value: any): any; parseContent(resources: any, attrName: any, attrValue: any): any; } - export class InterpolationBindingExpression { - constructor(observerLocator: any, targetProperty: any, parts: any, mode: any, valueConverterLookupFunction: any, attribute: any); - createBinding(target: any): any; - } - class InterpolationBinding { - constructor(observerLocator: any, parts: any, target: any, targetProperty: any, mode: any, valueConverterLookupFunction: any); - bind(source: any): any; - call(): any; - interpolate(connect: any, initial: any): any; - unbind(): any; - } export function configure(config: any): any; } \ No newline at end of file diff --git a/dist/system/aurelia-templating-binding.js b/dist/system/aurelia-templating-binding.js index 40fa1f0..21413b7 100644 --- a/dist/system/aurelia-templating-binding.js +++ b/dist/system/aurelia-templating-binding.js @@ -1,7 +1,7 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], function (_export) { 'use strict'; - var LogManager, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, bindingMode, NameExpression, connectable, BehaviorInstruction, BindingLanguage, SyntaxInterpreter, info, logger, TemplatingBindingLanguage, InterpolationBindingExpression, InterpolationBinding; + var LogManager, bindingMode, connectable, Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, CallExpression, NameExpression, BehaviorInstruction, BindingLanguage, InterpolationBindingExpression, InterpolationBinding, ChildInterpolationBinding, SyntaxInterpreter, info, TemplatingBindingLanguage; _export('configure', configure); @@ -10,38 +10,197 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function configure(config) { - var instance = undefined; - var getInstance = function getInstance(c) { - return instance || (instance = c.invoke(TemplatingBindingLanguage)); - }; - - if (config.container.hasHandler(TemplatingBindingLanguage)) { - instance = config.container.get(TemplatingBindingLanguage); - } else { - config.container.registerHandler(TemplatingBindingLanguage, getInstance); - } - - config.container.registerHandler(BindingLanguage, getInstance); + config.container.registerSingleton(BindingLanguage, TemplatingBindingLanguage); + config.container.registerAlias(BindingLanguage, TemplatingBindingLanguage); } return { setters: [function (_aureliaLogging) { LogManager = _aureliaLogging; }, function (_aureliaBinding) { + bindingMode = _aureliaBinding.bindingMode; + connectable = _aureliaBinding.connectable; Parser = _aureliaBinding.Parser; ObserverLocator = _aureliaBinding.ObserverLocator; EventManager = _aureliaBinding.EventManager; ListenerExpression = _aureliaBinding.ListenerExpression; BindingExpression = _aureliaBinding.BindingExpression; CallExpression = _aureliaBinding.CallExpression; - bindingMode = _aureliaBinding.bindingMode; NameExpression = _aureliaBinding.NameExpression; - connectable = _aureliaBinding.connectable; }, function (_aureliaTemplating) { BehaviorInstruction = _aureliaTemplating.BehaviorInstruction; BindingLanguage = _aureliaTemplating.BindingLanguage; }], execute: function () { + InterpolationBindingExpression = (function () { + function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, lookupFunctions, attribute) { + _classCallCheck(this, InterpolationBindingExpression); + + this.observerLocator = observerLocator; + this.targetProperty = targetProperty; + this.parts = parts; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + this.attribute = this.attrToRemove = attribute; + this.discrete = false; + } + + InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { + return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.lookupFunctions); + }; + + return InterpolationBindingExpression; + })(); + + _export('InterpolationBindingExpression', InterpolationBindingExpression); + + InterpolationBinding = (function () { + function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, lookupFunctions) { + _classCallCheck(this, InterpolationBinding); + + if (targetProperty === 'style') { + LogManager.getLogger('templating-binding').info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); + } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { + throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); + } + + this.observerLocator = observerLocator; + this.parts = parts; + this.targetProperty = observerLocator.getObserver(target, targetProperty); + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + InterpolationBinding.prototype.interpolate = function interpolate() { + if (this.isBound) { + var value = ''; + var parts = this.parts; + for (var i = 0, ii = parts.length; i < ii; i++) { + value += i % 2 === 0 ? parts[i] : this['childBinding' + i].value; + } + this.targetProperty.setValue(value); + } + }; + + InterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.source = source; + + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var binding = new ChildInterpolationBinding(this, this.observerLocator, parts[i], this.mode, this.lookupFunctions); + binding.bind(source); + this['childBinding' + i] = binding; + } + + this.isBound = true; + this.interpolate(); + }; + + InterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + this.source = null; + var parts = this.parts; + for (var i = 1, ii = parts.length; i < ii; i += 2) { + var _name = 'childBinding' + i; + this[_name].unbind(); + } + }; + + return InterpolationBinding; + })(); + + _export('InterpolationBinding', InterpolationBinding); + + ChildInterpolationBinding = (function () { + function ChildInterpolationBinding(parent, observerLocator, sourceExpression, mode, lookupFunctions) { + _classCallCheck(this, _ChildInterpolationBinding); + + this.parent = parent; + this.observerLocator = observerLocator; + this.sourceExpression = sourceExpression; + this.mode = mode; + this.lookupFunctions = lookupFunctions; + } + + ChildInterpolationBinding.prototype.updateTarget = function updateTarget(value) { + value = value === null || value === undefined ? '' : value.toString(); + if (value !== this.value) { + this.value = value; + this.parent.interpolate(); + } + }; + + ChildInterpolationBinding.prototype.call = function call() { + if (!this.isBound) { + return; + } + + var value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); + this.updateTarget(value); + + this._version++; + this.sourceExpression.connect(this, this.source); + if (value instanceof Array) { + this.observeArray(value); + } + this.unobserve(false); + }; + + ChildInterpolationBinding.prototype.bind = function bind(source) { + if (this.isBound) { + if (this.source === source) { + return; + } + this.unbind(); + } + this.isBound = true; + this.source = source; + + var sourceExpression = this.sourceExpression; + if (sourceExpression.bind) { + sourceExpression.bind(this, source, this.lookupFunctions); + } + + var value = sourceExpression.evaluate(source, this.lookupFunctions); + this.updateTarget(value); + + if (this.mode === bindingMode.oneWay) { + sourceExpression.connect(this, source); + if (value instanceof Array) { + this.observeArray(value); + } + } + }; + + ChildInterpolationBinding.prototype.unbind = function unbind() { + if (!this.isBound) { + return; + } + this.isBound = false; + var sourceExpression = this.sourceExpression; + if (sourceExpression.unbind) { + sourceExpression.unbind(this, this.source); + } + this.source = null; + this.unobserve(true); + }; + + var _ChildInterpolationBinding = ChildInterpolationBinding; + ChildInterpolationBinding = connectable()(ChildInterpolationBinding) || ChildInterpolationBinding; + return ChildInterpolationBinding; + })(); + + _export('ChildInterpolationBinding', ChildInterpolationBinding); + SyntaxInterpreter = (function () { SyntaxInterpreter.inject = function inject() { return [Parser, ObserverLocator, EventManager]; @@ -64,16 +223,8 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu }; SyntaxInterpreter.prototype.handleUnknownCommand = function handleUnknownCommand(resources, element, info, existingInstruction) { - var attrName = info.attrName; - var command = info.command; - var instruction = this.options(resources, element, info, existingInstruction); - - instruction.alteredAttr = true; - instruction.attrName = 'global-behavior'; - instruction.attributes.aureliaAttrName = attrName; - instruction.attributes.aureliaCommand = command; - - return instruction; + LogManager.getLogger('templating-binding').warn('Unknown binding command.', info); + return existingInstruction; }; SyntaxInterpreter.prototype.determineDefaultBindingMode = function determineDefaultBindingMode(element, attrName) { @@ -95,23 +246,23 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu SyntaxInterpreter.prototype.bind = function bind(resources, element, info, existingInstruction) { var instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), info.defaultBindingMode || this.determineDefaultBindingMode(element, info.attrName), resources.lookupFunctions); return instruction; }; SyntaxInterpreter.prototype.trigger = function trigger(resources, element, info) { - return new ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true); + return new ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), false, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.delegate = function delegate(resources, element, info) { - return new ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true); + return new ListenerExpression(this.eventManager, info.attrName, this.parser.parse(info.attrValue), true, true, resources.lookupFunctions); }; SyntaxInterpreter.prototype.call = function call(resources, element, info, existingInstruction) { var instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new CallExpression(this.observerLocator, info.attrName, this.parser.parse(info.attrValue), resources.lookupFunctions); return instruction; }; @@ -184,7 +335,7 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu instruction.attributes.local = parts[0]; } - instruction.attributes.items = new BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -192,7 +343,7 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu SyntaxInterpreter.prototype['two-way'] = function twoWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.twoWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.twoWay, resources.lookupFunctions); return instruction; }; @@ -200,7 +351,7 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu SyntaxInterpreter.prototype['one-way'] = function oneWay(resources, element, info, existingInstruction) { var instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneWay, resources.lookupFunctions); return instruction; }; @@ -208,7 +359,7 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu SyntaxInterpreter.prototype['one-time'] = function oneTime(resources, element, info, existingInstruction) { var instruction = existingInstruction || BehaviorInstruction.attribute(info.attrName); - instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneTime, resources.valueConverterLookupFunction); + instruction.attributes[info.attrName] = new BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), bindingMode.oneTime, resources.lookupFunctions); return instruction; }; @@ -219,7 +370,6 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu _export('SyntaxInterpreter', SyntaxInterpreter); info = {}; - logger = LogManager.getLogger('templating-binding'); TemplatingBindingLanguage = (function (_BindingLanguage) { _inherits(TemplatingBindingLanguage, _BindingLanguage); @@ -383,103 +533,13 @@ System.register(['aurelia-logging', 'aurelia-binding', 'aurelia-templating'], fu parts[partIndex] = attrValue.substr(pos); - return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, bindingMode.oneWay, resources.valueConverterLookupFunction, attrName); + return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, bindingMode.oneWay, resources.lookupFunctions, attrName); }; return TemplatingBindingLanguage; })(BindingLanguage); _export('TemplatingBindingLanguage', TemplatingBindingLanguage); - - InterpolationBindingExpression = (function () { - function InterpolationBindingExpression(observerLocator, targetProperty, parts, mode, valueConverterLookupFunction, attribute) { - _classCallCheck(this, InterpolationBindingExpression); - - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.parts = parts; - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - this.attribute = this.attrToRemove = attribute; - this.discrete = false; - } - - InterpolationBindingExpression.prototype.createBinding = function createBinding(target) { - return new InterpolationBinding(this.observerLocator, this.parts, target, this.targetProperty, this.mode, this.valueConverterLookupFunction); - }; - - return InterpolationBindingExpression; - })(); - - _export('InterpolationBindingExpression', InterpolationBindingExpression); - - InterpolationBinding = (function () { - function InterpolationBinding(observerLocator, parts, target, targetProperty, mode, valueConverterLookupFunction) { - _classCallCheck(this, _InterpolationBinding); - - if (targetProperty === 'style') { - logger.info('Internet Explorer does not support interpolation in "style" attributes. Use the style attribute\'s alias, "css" instead.'); - } else if (target.parentElement && target.parentElement.nodeName === 'TEXTAREA' && targetProperty === 'textContent') { - throw new Error('Interpolation binding cannot be used in the content of a textarea element. Use instead.'); - } - - this.observerLocator = observerLocator; - this.parts = parts; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.mode = mode; - this.valueConverterLookupFunction = valueConverterLookupFunction; - } - - InterpolationBinding.prototype.bind = function bind(source) { - if (this.source !== undefined) { - this.unbind(); - } - this.source = source; - this.interpolate(this.mode === bindingMode.oneWay, true); - }; - - InterpolationBinding.prototype.call = function call() { - if (this.source !== undefined) { - this._version++; - this.interpolate(this.mode === bindingMode.oneWay, false); - } - }; - - InterpolationBinding.prototype.interpolate = function interpolate(connect, initial) { - var value = ''; - var parts = this.parts; - var source = this.source; - var valueConverterLookupFunction = this.valueConverterLookupFunction; - - for (var i = 0, ii = parts.length; i < ii; ++i) { - if (i % 2 === 0) { - value += parts[i]; - } else { - var part = parts[i].evaluate(source, valueConverterLookupFunction); - value += part === undefined || part === null ? '' : part.toString(); - if (connect) { - parts[i].connect(this, source); - if (part instanceof Array) { - this.observeArray(part); - } - } - } - } - this.targetProperty.setValue(value); - if (!initial) { - this.unobserve(false); - } - }; - - InterpolationBinding.prototype.unbind = function unbind() { - this.source = undefined; - this.unobserve(true); - }; - - var _InterpolationBinding = InterpolationBinding; - InterpolationBinding = connectable()(InterpolationBinding) || InterpolationBinding; - return InterpolationBinding; - })(); } }; }); \ No newline at end of file diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 122a024..de71f55 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,17 @@ +## 0.17.0 (2015-11-10) + + +#### Bug Fixes + +* **all:** remove support for the global fallback binding command ([5eb01aa5](http://github.com/aurelia/templating-binding/commit/5eb01aa5ef116c81995c37864835f48eef84236f)) +* **index:** update to latest container api ([f7001741](http://github.com/aurelia/templating-binding/commit/f7001741e7b6f26c15dd04faf8bcfa2677e7c9d3)) + + +#### Features + +* **binding-behaviors:** add support for binding behaviors ([5fa455bd](http://github.com/aurelia/templating-binding/commit/5fa455bd5e50dce06073e80b073b619e4b1a5e27)) + + ### 0.16.1 (2015-10-15) diff --git a/doc/api.json b/doc/api.json index a6fb232..dfb33b1 100644 --- a/doc/api.json +++ b/doc/api.json @@ -6,29 +6,33 @@ "flags": {}, "children": [ { - "id": 119, - "name": "InterpolationBinding", + "id": 31, + "name": "ChildInterpolationBinding", "kind": 128, "kindString": "Class", - "flags": {}, + "flags": { + "isExported": true + }, "children": [ { - "id": 120, + "id": 32, "name": "constructor", "kind": 512, "kindString": "Constructor", - "flags": {}, + "flags": { + "isExported": true + }, "signatures": [ { - "id": 121, - "name": "new InterpolationBinding", + "id": 33, + "name": "new ChildInterpolationBinding", "kind": 16384, "kindString": "Constructor signature", "flags": {}, "parameters": [ { - "id": 122, - "name": "observerLocator", + "id": 34, + "name": "parent", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -38,19 +42,8 @@ } }, { - "id": 123, - "name": "parts", - "kind": 32768, - "kindString": "Parameter", - "flags": {}, - "type": { - "type": "instrinct", - "name": "any" - } - }, - { - "id": 124, - "name": "target", + "id": 35, + "name": "observerLocator", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -60,8 +53,8 @@ } }, { - "id": 125, - "name": "targetProperty", + "id": 36, + "name": "sourceExpression", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -71,7 +64,7 @@ } }, { - "id": 126, + "id": 37, "name": "mode", "kind": 32768, "kindString": "Parameter", @@ -82,8 +75,8 @@ } }, { - "id": 127, - "name": "valueConverterLookupFunction", + "id": 38, + "name": "lookupFunctions", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -95,29 +88,31 @@ ], "type": { "type": "reference", - "name": "InterpolationBinding", - "id": 119, + "name": "ChildInterpolationBinding", + "id": 31, "moduleName": "\"aurelia-templating-binding\"" } } ] }, { - "id": 128, + "id": 44, "name": "bind", "kind": 2048, "kindString": "Method", - "flags": {}, + "flags": { + "isExported": true + }, "signatures": [ { - "id": 129, + "id": 45, "name": "bind", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 130, + "id": 46, "name": "source", "kind": 32768, "kindString": "Parameter", @@ -136,14 +131,16 @@ ] }, { - "id": 131, + "id": 42, "name": "call", "kind": 2048, "kindString": "Method", - "flags": {}, + "flags": { + "isExported": true + }, "signatures": [ { - "id": 132, + "id": 43, "name": "call", "kind": 4096, "kindString": "Call signature", @@ -156,22 +153,111 @@ ] }, { - "id": 133, - "name": "interpolate", + "id": 47, + "name": "unbind", "kind": 2048, "kindString": "Method", - "flags": {}, + "flags": { + "isExported": true + }, "signatures": [ { - "id": 134, - "name": "interpolate", + "id": 48, + "name": "unbind", + "kind": 4096, + "kindString": "Call signature", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + } + ] + }, + { + "id": 39, + "name": "updateTarget", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 40, + "name": "updateTarget", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 135, - "name": "connect", + "id": 41, + "name": "value", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + } + ], + "type": { + "type": "instrinct", + "name": "any" + } + } + ] + } + ], + "groups": [ + { + "title": "Constructors", + "kind": 512, + "children": [ + 32 + ] + }, + { + "title": "Methods", + "kind": 2048, + "children": [ + 44, + 42, + 47, + 39 + ] + } + ] + }, + { + "id": 15, + "name": "InterpolationBinding", + "kind": 128, + "kindString": "Class", + "flags": { + "isExported": true + }, + "children": [ + { + "id": 16, + "name": "constructor", + "kind": 512, + "kindString": "Constructor", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 17, + "name": "new InterpolationBinding", + "kind": 16384, + "kindString": "Constructor signature", + "flags": {}, + "parameters": [ + { + "id": 18, + "name": "observerLocator", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -181,8 +267,52 @@ } }, { - "id": 136, - "name": "initial", + "id": 19, + "name": "parts", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + }, + { + "id": 20, + "name": "target", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + }, + { + "id": 21, + "name": "targetProperty", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + }, + { + "id": 22, + "name": "mode", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + }, + { + "id": 23, + "name": "lookupFunctions", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -192,6 +322,65 @@ } } ], + "type": { + "type": "reference", + "name": "InterpolationBinding", + "id": 15, + "moduleName": "\"aurelia-templating-binding\"" + } + } + ] + }, + { + "id": 26, + "name": "bind", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 27, + "name": "bind", + "kind": 4096, + "kindString": "Call signature", + "flags": {}, + "parameters": [ + { + "id": 28, + "name": "source", + "kind": 32768, + "kindString": "Parameter", + "flags": {}, + "type": { + "type": "instrinct", + "name": "any" + } + } + ], + "type": { + "type": "instrinct", + "name": "any" + } + } + ] + }, + { + "id": 24, + "name": "interpolate", + "kind": 2048, + "kindString": "Method", + "flags": { + "isExported": true + }, + "signatures": [ + { + "id": 25, + "name": "interpolate", + "kind": 4096, + "kindString": "Call signature", + "flags": {}, "type": { "type": "instrinct", "name": "any" @@ -200,14 +389,16 @@ ] }, { - "id": 137, + "id": 29, "name": "unbind", "kind": 2048, "kindString": "Method", - "flags": {}, + "flags": { + "isExported": true + }, "signatures": [ { - "id": 138, + "id": 30, "name": "unbind", "kind": 4096, "kindString": "Call signature", @@ -225,23 +416,22 @@ "title": "Constructors", "kind": 512, "children": [ - 120 + 16 ] }, { "title": "Methods", "kind": 2048, "children": [ - 128, - 131, - 133, - 137 + 26, + 24, + 29 ] } ] }, { - "id": 107, + "id": 3, "name": "InterpolationBindingExpression", "kind": 128, "kindString": "Class", @@ -250,7 +440,7 @@ }, "children": [ { - "id": 108, + "id": 4, "name": "constructor", "kind": 512, "kindString": "Constructor", @@ -259,14 +449,14 @@ }, "signatures": [ { - "id": 109, + "id": 5, "name": "new InterpolationBindingExpression", "kind": 16384, "kindString": "Constructor signature", "flags": {}, "parameters": [ { - "id": 110, + "id": 6, "name": "observerLocator", "kind": 32768, "kindString": "Parameter", @@ -277,7 +467,7 @@ } }, { - "id": 111, + "id": 7, "name": "targetProperty", "kind": 32768, "kindString": "Parameter", @@ -288,7 +478,7 @@ } }, { - "id": 112, + "id": 8, "name": "parts", "kind": 32768, "kindString": "Parameter", @@ -299,7 +489,7 @@ } }, { - "id": 113, + "id": 9, "name": "mode", "kind": 32768, "kindString": "Parameter", @@ -310,8 +500,8 @@ } }, { - "id": 114, - "name": "valueConverterLookupFunction", + "id": 10, + "name": "lookupFunctions", "kind": 32768, "kindString": "Parameter", "flags": {}, @@ -321,7 +511,7 @@ } }, { - "id": 115, + "id": 11, "name": "attribute", "kind": 32768, "kindString": "Parameter", @@ -335,14 +525,14 @@ "type": { "type": "reference", "name": "InterpolationBindingExpression", - "id": 107, + "id": 3, "moduleName": "\"aurelia-templating-binding\"" } } ] }, { - "id": 116, + "id": 12, "name": "createBinding", "kind": 2048, "kindString": "Method", @@ -351,14 +541,14 @@ }, "signatures": [ { - "id": 117, + "id": 13, "name": "createBinding", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 118, + "id": 14, "name": "target", "kind": 32768, "kindString": "Parameter", @@ -382,20 +572,20 @@ "title": "Constructors", "kind": 512, "children": [ - 108 + 4 ] }, { "title": "Methods", "kind": 2048, "children": [ - 116 + 12 ] } ] }, { - "id": 3, + "id": 49, "name": "SyntaxInterpreter", "kind": 128, "kindString": "Class", @@ -404,7 +594,7 @@ }, "children": [ { - "id": 6, + "id": 52, "name": "constructor", "kind": 512, "kindString": "Constructor", @@ -413,14 +603,14 @@ }, "signatures": [ { - "id": 7, + "id": 53, "name": "new SyntaxInterpreter", "kind": 16384, "kindString": "Constructor signature", "flags": {}, "parameters": [ { - "id": 8, + "id": 54, "name": "parser", "kind": 32768, "kindString": "Parameter", @@ -431,7 +621,7 @@ } }, { - "id": 9, + "id": 55, "name": "observerLocator", "kind": 32768, "kindString": "Parameter", @@ -442,7 +632,7 @@ } }, { - "id": 10, + "id": 56, "name": "eventManager", "kind": 32768, "kindString": "Parameter", @@ -456,14 +646,14 @@ "type": { "type": "reference", "name": "SyntaxInterpreter", - "id": 3, + "id": 49, "moduleName": "\"aurelia-templating-binding\"" } } ] }, { - "id": 27, + "id": 73, "name": "bind", "kind": 2048, "kindString": "Method", @@ -472,14 +662,14 @@ }, "signatures": [ { - "id": 28, + "id": 74, "name": "bind", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 29, + "id": 75, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -490,7 +680,7 @@ } }, { - "id": 30, + "id": 76, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -501,7 +691,7 @@ } }, { - "id": 31, + "id": 77, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -512,7 +702,7 @@ } }, { - "id": 32, + "id": 78, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -531,7 +721,7 @@ ] }, { - "id": 43, + "id": 89, "name": "call", "kind": 2048, "kindString": "Method", @@ -540,14 +730,14 @@ }, "signatures": [ { - "id": 44, + "id": 90, "name": "call", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 45, + "id": 91, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -558,7 +748,7 @@ } }, { - "id": 46, + "id": 92, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -569,7 +759,7 @@ } }, { - "id": 47, + "id": 93, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -580,7 +770,7 @@ } }, { - "id": 48, + "id": 94, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -599,7 +789,7 @@ ] }, { - "id": 38, + "id": 84, "name": "delegate", "kind": 2048, "kindString": "Method", @@ -608,14 +798,14 @@ }, "signatures": [ { - "id": 39, + "id": 85, "name": "delegate", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 40, + "id": 86, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -626,7 +816,7 @@ } }, { - "id": 41, + "id": 87, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -637,7 +827,7 @@ } }, { - "id": 42, + "id": 88, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -656,7 +846,7 @@ ] }, { - "id": 23, + "id": 69, "name": "determineDefaultBindingMode", "kind": 2048, "kindString": "Method", @@ -665,14 +855,14 @@ }, "signatures": [ { - "id": 24, + "id": 70, "name": "determineDefaultBindingMode", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 25, + "id": 71, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -683,7 +873,7 @@ } }, { - "id": 26, + "id": 72, "name": "attrName", "kind": 32768, "kindString": "Parameter", @@ -702,7 +892,7 @@ ] }, { - "id": 55, + "id": 101, "name": "for", "kind": 2048, "kindString": "Method", @@ -711,14 +901,14 @@ }, "signatures": [ { - "id": 56, + "id": 102, "name": "for", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 57, + "id": 103, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -729,7 +919,7 @@ } }, { - "id": 58, + "id": 104, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -740,7 +930,7 @@ } }, { - "id": 59, + "id": 105, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -751,7 +941,7 @@ } }, { - "id": 60, + "id": 106, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -770,7 +960,7 @@ ] }, { - "id": 17, + "id": 63, "name": "handleUnknownCommand", "kind": 2048, "kindString": "Method", @@ -779,14 +969,14 @@ }, "signatures": [ { - "id": 18, + "id": 64, "name": "handleUnknownCommand", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 19, + "id": 65, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -797,7 +987,7 @@ } }, { - "id": 20, + "id": 66, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -808,7 +998,7 @@ } }, { - "id": 21, + "id": 67, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -819,7 +1009,7 @@ } }, { - "id": 22, + "id": 68, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -838,7 +1028,7 @@ ] }, { - "id": 11, + "id": 57, "name": "interpret", "kind": 2048, "kindString": "Method", @@ -847,14 +1037,14 @@ }, "signatures": [ { - "id": 12, + "id": 58, "name": "interpret", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 13, + "id": 59, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -865,7 +1055,7 @@ } }, { - "id": 14, + "id": 60, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -876,7 +1066,7 @@ } }, { - "id": 15, + "id": 61, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -887,7 +1077,7 @@ } }, { - "id": 16, + "id": 62, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -906,7 +1096,7 @@ ] }, { - "id": 73, + "id": 119, "name": "one-time", "kind": 2048, "kindString": "Method", @@ -915,14 +1105,14 @@ }, "signatures": [ { - "id": 74, + "id": 120, "name": "one-time", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 75, + "id": 121, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -933,7 +1123,7 @@ } }, { - "id": 76, + "id": 122, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -944,7 +1134,7 @@ } }, { - "id": 77, + "id": 123, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -955,7 +1145,7 @@ } }, { - "id": 78, + "id": 124, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -974,7 +1164,7 @@ ] }, { - "id": 67, + "id": 113, "name": "one-way", "kind": 2048, "kindString": "Method", @@ -983,14 +1173,14 @@ }, "signatures": [ { - "id": 68, + "id": 114, "name": "one-way", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 69, + "id": 115, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1001,7 +1191,7 @@ } }, { - "id": 70, + "id": 116, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -1012,7 +1202,7 @@ } }, { - "id": 71, + "id": 117, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -1023,7 +1213,7 @@ } }, { - "id": 72, + "id": 118, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -1042,7 +1232,7 @@ ] }, { - "id": 49, + "id": 95, "name": "options", "kind": 2048, "kindString": "Method", @@ -1051,14 +1241,14 @@ }, "signatures": [ { - "id": 50, + "id": 96, "name": "options", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 51, + "id": 97, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1069,7 +1259,7 @@ } }, { - "id": 52, + "id": 98, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -1080,7 +1270,7 @@ } }, { - "id": 53, + "id": 99, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -1091,7 +1281,7 @@ } }, { - "id": 54, + "id": 100, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -1110,7 +1300,7 @@ ] }, { - "id": 33, + "id": 79, "name": "trigger", "kind": 2048, "kindString": "Method", @@ -1119,14 +1309,14 @@ }, "signatures": [ { - "id": 34, + "id": 80, "name": "trigger", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 35, + "id": 81, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1137,7 +1327,7 @@ } }, { - "id": 36, + "id": 82, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -1148,7 +1338,7 @@ } }, { - "id": 37, + "id": 83, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -1167,7 +1357,7 @@ ] }, { - "id": 61, + "id": 107, "name": "two-way", "kind": 2048, "kindString": "Method", @@ -1176,14 +1366,14 @@ }, "signatures": [ { - "id": 62, + "id": 108, "name": "two-way", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 63, + "id": 109, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1194,7 +1384,7 @@ } }, { - "id": 64, + "id": 110, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -1205,7 +1395,7 @@ } }, { - "id": 65, + "id": 111, "name": "info", "kind": 32768, "kindString": "Parameter", @@ -1216,7 +1406,7 @@ } }, { - "id": 66, + "id": 112, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -1235,7 +1425,7 @@ ] }, { - "id": 4, + "id": 50, "name": "inject", "kind": 2048, "kindString": "Method", @@ -1245,7 +1435,7 @@ }, "signatures": [ { - "id": 5, + "id": 51, "name": "inject", "kind": 4096, "kindString": "Call signature", @@ -1263,32 +1453,32 @@ "title": "Constructors", "kind": 512, "children": [ - 6 + 52 ] }, { "title": "Methods", "kind": 2048, "children": [ - 27, - 43, - 38, - 23, - 55, - 17, - 11, 73, - 67, - 49, - 33, - 61, - 4 + 89, + 84, + 69, + 101, + 63, + 57, + 119, + 113, + 95, + 79, + 107, + 50 ] } ] }, { - "id": 79, + "id": 125, "name": "TemplatingBindingLanguage", "kind": 128, "kindString": "Class", @@ -1297,7 +1487,7 @@ }, "children": [ { - "id": 82, + "id": 128, "name": "constructor", "kind": 512, "kindString": "Constructor", @@ -1306,14 +1496,14 @@ }, "signatures": [ { - "id": 83, + "id": 129, "name": "new TemplatingBindingLanguage", "kind": 16384, "kindString": "Constructor signature", "flags": {}, "parameters": [ { - "id": 84, + "id": 130, "name": "parser", "kind": 32768, "kindString": "Parameter", @@ -1324,7 +1514,7 @@ } }, { - "id": 85, + "id": 131, "name": "observerLocator", "kind": 32768, "kindString": "Parameter", @@ -1335,7 +1525,7 @@ } }, { - "id": 86, + "id": 132, "name": "syntaxInterpreter", "kind": 32768, "kindString": "Parameter", @@ -1349,14 +1539,14 @@ "type": { "type": "reference", "name": "TemplatingBindingLanguage", - "id": 79, + "id": 125, "moduleName": "\"aurelia-templating-binding\"" } } ] }, { - "id": 92, + "id": 138, "name": "createAttributeInstruction", "kind": 2048, "kindString": "Method", @@ -1365,14 +1555,14 @@ }, "signatures": [ { - "id": 93, + "id": 139, "name": "createAttributeInstruction", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 94, + "id": 140, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1383,7 +1573,7 @@ } }, { - "id": 95, + "id": 141, "name": "element", "kind": 32768, "kindString": "Parameter", @@ -1394,7 +1584,7 @@ } }, { - "id": 96, + "id": 142, "name": "theInfo", "kind": 32768, "kindString": "Parameter", @@ -1405,7 +1595,7 @@ } }, { - "id": 97, + "id": 143, "name": "existingInstruction", "kind": 32768, "kindString": "Parameter", @@ -1423,18 +1613,18 @@ "overwrites": { "type": "reference", "name": "BindingLanguage.createAttributeInstruction", - "id": 2127 + "id": 2328 } } ], "overwrites": { "type": "reference", "name": "BindingLanguage.createAttributeInstruction", - "id": 2127 + "id": 2328 } }, { - "id": 87, + "id": 133, "name": "inspectAttribute", "kind": 2048, "kindString": "Method", @@ -1443,14 +1633,14 @@ }, "signatures": [ { - "id": 88, + "id": 134, "name": "inspectAttribute", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 89, + "id": 135, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1461,7 +1651,7 @@ } }, { - "id": 90, + "id": 136, "name": "attrName", "kind": 32768, "kindString": "Parameter", @@ -1472,7 +1662,7 @@ } }, { - "id": 91, + "id": 137, "name": "attrValue", "kind": 32768, "kindString": "Parameter", @@ -1490,18 +1680,18 @@ "overwrites": { "type": "reference", "name": "BindingLanguage.inspectAttribute", - "id": 2122 + "id": 2323 } } ], "overwrites": { "type": "reference", "name": "BindingLanguage.inspectAttribute", - "id": 2122 + "id": 2323 } }, { - "id": 102, + "id": 148, "name": "parseContent", "kind": 2048, "kindString": "Method", @@ -1510,14 +1700,14 @@ }, "signatures": [ { - "id": 103, + "id": 149, "name": "parseContent", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 104, + "id": 150, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1528,7 +1718,7 @@ } }, { - "id": 105, + "id": 151, "name": "attrName", "kind": 32768, "kindString": "Parameter", @@ -1539,7 +1729,7 @@ } }, { - "id": 106, + "id": 152, "name": "attrValue", "kind": 32768, "kindString": "Parameter", @@ -1558,7 +1748,7 @@ ] }, { - "id": 98, + "id": 144, "name": "parseText", "kind": 2048, "kindString": "Method", @@ -1567,14 +1757,14 @@ }, "signatures": [ { - "id": 99, + "id": 145, "name": "parseText", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 100, + "id": 146, "name": "resources", "kind": 32768, "kindString": "Parameter", @@ -1585,7 +1775,7 @@ } }, { - "id": 101, + "id": 147, "name": "value", "kind": 32768, "kindString": "Parameter", @@ -1603,18 +1793,18 @@ "overwrites": { "type": "reference", "name": "BindingLanguage.parseText", - "id": 2133 + "id": 2334 } } ], "overwrites": { "type": "reference", "name": "BindingLanguage.parseText", - "id": 2133 + "id": 2334 } }, { - "id": 80, + "id": 126, "name": "inject", "kind": 2048, "kindString": "Method", @@ -1624,7 +1814,7 @@ }, "signatures": [ { - "id": 81, + "id": 127, "name": "inject", "kind": 4096, "kindString": "Call signature", @@ -1642,18 +1832,18 @@ "title": "Constructors", "kind": 512, "children": [ - 82 + 128 ] }, { "title": "Methods", "kind": 2048, "children": [ - 92, - 87, - 102, - 98, - 80 + 138, + 133, + 148, + 144, + 126 ] } ], @@ -1661,12 +1851,12 @@ { "type": "reference", "name": "BindingLanguage", - "id": 2121 + "id": 2322 } ] }, { - "id": 139, + "id": 153, "name": "configure", "kind": 64, "kindString": "Function", @@ -1675,14 +1865,14 @@ }, "signatures": [ { - "id": 140, + "id": 154, "name": "configure", "kind": 4096, "kindString": "Call signature", "flags": {}, "parameters": [ { - "id": 141, + "id": 155, "name": "config", "kind": 32768, "kindString": "Parameter", @@ -1706,17 +1896,18 @@ "title": "Classes", "kind": 128, "children": [ - 119, - 107, + 31, + 15, 3, - 79 + 49, + 125 ] }, { "title": "Functions", "kind": 64, "children": [ - 139 + 153 ] } ] diff --git a/package.json b/package.json index f30f1e1..0a81234 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-binding", - "version": "0.16.1", + "version": "0.17.0", "description": "An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.", "keywords": [ "aurelia", @@ -31,9 +31,9 @@ "aurelia-templating": "github:aurelia/templating@^0.17.0" }, "devDependencies": { - "aurelia-pal": "github:aurelia/pal@^0.2.0", - "aurelia-pal-browser": "github:aurelia/pal-browser@^0.2.0", - "aurelia-task-queue": "github:aurelia/task-queue@^0.8.0", + "aurelia-pal": "github:aurelia/pal@^0.3.0", + "aurelia-pal-browser": "github:aurelia/pal-browser@^0.3.0", + "aurelia-task-queue": "github:aurelia/task-queue@^0.9.0", "babel": "npm:babel-core@^5.1.13", "babel-runtime": "npm:babel-runtime@^5.1.13", "core-js": "npm:core-js@^1.2.6"