From cc49716cf3e12311ea1a2252844ec077a970309b Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Mon, 8 Jun 2015 22:55:48 -0400 Subject: [PATCH] chore(all): prepare release 0.12.0 --- bower.json | 8 ++-- config.js | 60 +++++++++++++------------- dist/amd/binding-language.js | 44 ++++++++++++------- dist/amd/syntax-interpreter.js | 31 +++++++------- dist/commonjs/binding-language.js | 66 +++++++++++++++++------------ dist/commonjs/index.js | 20 ++++----- dist/commonjs/syntax-interpreter.js | 57 ++++++++++++------------- dist/es6/binding-language.js | 14 +++++- dist/es6/syntax-interpreter.js | 37 ++++++++-------- dist/system/binding-language.js | 52 ++++++++++++++--------- dist/system/index.js | 4 +- dist/system/syntax-interpreter.js | 37 ++++++++-------- doc/CHANGELOG.md | 16 +++++++ package.json | 8 ++-- 14 files changed, 257 insertions(+), 197 deletions(-) diff --git a/bower.json b/bower.json index 71be1c2..bf925a6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-binding", - "version": "0.11.0", + "version": "0.12.0", "description": "An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.", "keywords": [ "aurelia", @@ -18,8 +18,8 @@ "url": "http://github.com/aurelia/templating-binding" }, "dependencies": { - "aurelia-binding": "^0.6.0", - "aurelia-logging": "^0.4.0", - "aurelia-templating": "^0.11.0" + "aurelia-binding": "^0.7.0", + "aurelia-logging": "^0.5.0", + "aurelia-templating": "^0.12.0" } } diff --git a/config.js b/config.js index 9c3e98b..7407c1c 100644 --- a/config.js +++ b/config.js @@ -16,48 +16,50 @@ System.config({ System.config({ "map": { - "aurelia-binding": "github:aurelia/binding@0.6.0", - "aurelia-logging": "github:aurelia/logging@0.4.0", - "aurelia-templating": "github:aurelia/templating@0.11.0", + "aurelia-binding": "github:aurelia/binding@0.7.0", + "aurelia-logging": "github:aurelia/logging@0.5.0", + "aurelia-templating": "github:aurelia/templating@0.12.0", "babel": "npm:babel-core@5.2.2", "babel-runtime": "npm:babel-runtime@5.2.2", - "core-js": "npm:core-js@0.9.5", - "github:aurelia/binding@0.6.0": { - "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.7.0", - "aurelia-metadata": "github:aurelia/metadata@0.5.0", - "aurelia-task-queue": "github:aurelia/task-queue@0.4.0", - "core-js": "npm:core-js@0.9.5" + "core-js": "npm:core-js@0.9.14", + "github:aurelia/binding@0.7.0": { + "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.8.1", + "aurelia-metadata": "github:aurelia/metadata@0.6.0", + "aurelia-task-queue": "github:aurelia/task-queue@0.5.0", + "core-js": "npm:core-js@0.9.14" }, - "github:aurelia/dependency-injection@0.7.0": { - "aurelia-logging": "github:aurelia/logging@0.4.0", - "aurelia-metadata": "github:aurelia/metadata@0.5.0", - "core-js": "npm:core-js@0.9.5" + "github:aurelia/dependency-injection@0.8.1": { + "aurelia-logging": "github:aurelia/logging@0.5.0", + "aurelia-metadata": "github:aurelia/metadata@0.6.0", + "core-js": "npm:core-js@0.9.14" }, - "github:aurelia/loader@0.6.0": { + "github:aurelia/loader@0.7.0": { "aurelia-html-template-element": "github:aurelia/html-template-element@0.2.0", - "aurelia-path": "github:aurelia/path@0.6.0", - "core-js": "npm:core-js@0.9.5", - "webcomponentsjs": "github:webcomponents/webcomponentsjs@0.6.1" + "aurelia-path": "github:aurelia/path@0.7.0", + "core-js": "npm:core-js@0.9.14", + "webcomponentsjs": "github:webcomponents/webcomponentsjs@0.6.3" }, - "github:aurelia/metadata@0.5.0": { - "core-js": "npm:core-js@0.9.5" + "github:aurelia/metadata@0.6.0": { + "core-js": "npm:core-js@0.9.14" }, - "github:aurelia/templating@0.11.0": { - "aurelia-binding": "github:aurelia/binding@0.6.0", - "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.7.0", + "github:aurelia/templating@0.12.0": { + "aurelia-binding": "github:aurelia/binding@0.7.0", + "aurelia-dependency-injection": "github:aurelia/dependency-injection@0.8.1", "aurelia-html-template-element": "github:aurelia/html-template-element@0.2.0", - "aurelia-loader": "github:aurelia/loader@0.6.0", - "aurelia-logging": "github:aurelia/logging@0.4.0", - "aurelia-metadata": "github:aurelia/metadata@0.5.0", - "aurelia-path": "github:aurelia/path@0.6.0", - "aurelia-task-queue": "github:aurelia/task-queue@0.4.0", - "core-js": "npm:core-js@0.9.5" + "aurelia-loader": "github:aurelia/loader@0.7.0", + "aurelia-logging": "github:aurelia/logging@0.5.0", + "aurelia-metadata": "github:aurelia/metadata@0.6.0", + "aurelia-path": "github:aurelia/path@0.7.0", + "aurelia-task-queue": "github:aurelia/task-queue@0.5.0", + "core-js": "npm:core-js@0.9.14" }, "github:jspm/nodelibs-process@0.1.1": { "process": "npm:process@0.10.1" }, - "npm:core-js@0.9.5": { + "npm:core-js@0.9.14": { + "fs": "github:jspm/nodelibs-fs@0.1.2", "process": "github:jspm/nodelibs-process@0.1.1" } } }); + diff --git a/dist/amd/binding-language.js b/dist/amd/binding-language.js index 8455289..64bc9ca 100644 --- a/dist/amd/binding-language.js +++ b/dist/amd/binding-language.js @@ -1,11 +1,11 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', './syntax-interpreter', 'aurelia-logging'], function (exports, _aureliaTemplating, _aureliaBinding, _syntaxInterpreter, _aureliaLogging) { 'use strict'; - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; + exports.__esModule = true; - var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - exports.__esModule = true; + function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } var info = {}, logger = _aureliaLogging.getLogger('templating-binding'); @@ -21,19 +21,24 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', './syntax-interprete this.emptyStringExpression = this.parser.parse('\'\''); syntaxInterpreter.language = this; this.attributeMap = syntaxInterpreter.attributeMap = { - 'class': 'className', - contenteditable: 'contentEditable', + 'contenteditable': 'contentEditable', 'for': 'htmlFor', - tabindex: 'tabIndex', - textcontent: 'textContent', - innerhtml: 'innerHTML', - maxlength: 'maxLength', - minlength: 'minLength', - formaction: 'formAction', - formenctype: 'formEncType', - formmethod: 'formMethod', - formnovalidate: 'formNoValidate', - formtarget: 'formTarget' }; + 'tabindex': 'tabIndex', + 'textcontent': 'textContent', + 'innerhtml': 'innerHTML', + + 'maxlength': 'maxLength', + 'minlength': 'minLength', + 'formaction': 'formAction', + 'formenctype': 'formEncType', + 'formmethod': 'formMethod', + 'formnovalidate': 'formNoValidate', + 'formtarget': 'formTarget', + 'rowspan': 'rowSpan', + 'colspan': 'colSpan', + 'scrolltop': 'scrollTop', + 'scrollleft': 'scrollLeft' + }; } _inherits(TemplatingBindingLanguage, _BindingLanguage); @@ -51,7 +56,14 @@ define(['exports', 'aurelia-templating', 'aurelia-binding', './syntax-interprete info.attrName = parts[0].trim(); info.attrValue = attrValue; info.command = parts[1].trim(); - info.expression = null; + + if (info.command === 'ref') { + info.expression = new _aureliaBinding.NameExpression(attrValue, info.attrName); + info.command = null; + info.attrName = 'ref'; + } else { + info.expression = null; + } } else if (attrName == 'ref') { info.attrName = attrName; info.attrValue = attrValue; diff --git a/dist/amd/syntax-interpreter.js b/dist/amd/syntax-interpreter.js index a29719c..f89753a 100644 --- a/dist/amd/syntax-interpreter.js +++ b/dist/amd/syntax-interpreter.js @@ -1,10 +1,10 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { 'use strict'; - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; - exports.__esModule = true; + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + var SyntaxInterpreter = (function () { function SyntaxInterpreter(parser, observerLocator, eventManager) { _classCallCheck(this, SyntaxInterpreter); @@ -49,6 +49,8 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { return attrName == 'value' ? _aureliaBinding.bindingMode.twoWay : _aureliaBinding.bindingMode.oneWay; } else if (attrName === 'textcontent' || attrName === 'innerhtml') { return element.contentEditable === 'true' ? _aureliaBinding.bindingMode.twoWay : _aureliaBinding.bindingMode.oneWay; + } else if (attrName === 'scrolltop' || attrName === 'scrollleft') { + return _aureliaBinding.bindingMode.twoWay; } return _aureliaBinding.bindingMode.oneWay; @@ -127,25 +129,26 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { exports.SyntaxInterpreter = SyntaxInterpreter; SyntaxInterpreter.prototype['for'] = function (resources, element, info, existingInstruction) { - var parts = info.attrValue.split(' of '); + var parts, keyValue, instruction, attrValue, isDestructuring; + attrValue = info.attrValue; + isDestructuring = attrValue.match(/[[].+[\]]/); + parts = isDestructuring ? attrValue.split('of ') : attrValue.split(' of '); if (parts.length !== 2) { - throw new Error('Incorrect syntax for "for". The form is: "$local of $items".'); + throw new Error('Incorrect syntax for "for". The form is: "$local of $items" or "[$key, $value] of $items".'); } - var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; + instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - if (parts[0].match(/[[].+[,]\s.+[\]]/)) { - var firstPart = parts[0]; - parts[0] = firstPart.substr(1, firstPart.indexOf(',') - 1); - parts.splice(1, 0, firstPart.substring(firstPart.indexOf(', ') + 2, firstPart.length - 1)); - instruction.attributes.key = parts[0]; - instruction.attributes.value = parts[1]; + if (isDestructuring) { + keyValue = parts[0].replace(/[[\]]/g, '').replace(/,/g, ' ').replace(/\s+/g, ' ').trim().split(' '); + instruction.attributes.key = keyValue[0]; + instruction.attributes.value = keyValue[1]; } else { instruction.attributes.local = parts[0]; } - instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[parts.length - 1]), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); return instruction; }; @@ -173,8 +176,4 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { return instruction; }; - - SyntaxInterpreter.prototype['view-model'] = function (resources, element, info) { - return new _aureliaBinding.NameExpression(info.attrValue, 'view-model'); - }; }); \ No newline at end of file diff --git a/dist/commonjs/binding-language.js b/dist/commonjs/binding-language.js index ee8ef57..c64076b 100644 --- a/dist/commonjs/binding-language.js +++ b/dist/commonjs/binding-language.js @@ -1,22 +1,22 @@ 'use strict'; -var _interopRequireWildcard = function (obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (typeof obj === 'object' && obj !== null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }; +exports.__esModule = true; -var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } -var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } -exports.__esModule = true; +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } -var _BindingLanguage2 = require('aurelia-templating'); +var _aureliaTemplating = require('aurelia-templating'); -var _Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode = require('aurelia-binding'); +var _aureliaBinding = require('aurelia-binding'); -var _SyntaxInterpreter = require('./syntax-interpreter'); +var _syntaxInterpreter = require('./syntax-interpreter'); -var _import = require('aurelia-logging'); +var _aureliaLogging = require('aurelia-logging'); -var LogManager = _interopRequireWildcard(_import); +var LogManager = _interopRequireWildcard(_aureliaLogging); var info = {}, logger = LogManager.getLogger('templating-binding'); @@ -32,25 +32,30 @@ var TemplatingBindingLanguage = (function (_BindingLanguage) { this.emptyStringExpression = this.parser.parse('\'\''); syntaxInterpreter.language = this; this.attributeMap = syntaxInterpreter.attributeMap = { - 'class': 'className', - contenteditable: 'contentEditable', + 'contenteditable': 'contentEditable', 'for': 'htmlFor', - tabindex: 'tabIndex', - textcontent: 'textContent', - innerhtml: 'innerHTML', - maxlength: 'maxLength', - minlength: 'minLength', - formaction: 'formAction', - formenctype: 'formEncType', - formmethod: 'formMethod', - formnovalidate: 'formNoValidate', - formtarget: 'formTarget' }; + 'tabindex': 'tabIndex', + 'textcontent': 'textContent', + 'innerhtml': 'innerHTML', + + 'maxlength': 'maxLength', + 'minlength': 'minLength', + 'formaction': 'formAction', + 'formenctype': 'formEncType', + 'formmethod': 'formMethod', + 'formnovalidate': 'formNoValidate', + 'formtarget': 'formTarget', + 'rowspan': 'rowSpan', + 'colspan': 'colSpan', + 'scrolltop': 'scrollTop', + 'scrollleft': 'scrollLeft' + }; } _inherits(TemplatingBindingLanguage, _BindingLanguage); TemplatingBindingLanguage.inject = function inject() { - return [_Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode.Parser, _Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode.ObserverLocator, _SyntaxInterpreter.SyntaxInterpreter]; + return [_aureliaBinding.Parser, _aureliaBinding.ObserverLocator, _syntaxInterpreter.SyntaxInterpreter]; }; TemplatingBindingLanguage.prototype.inspectAttribute = function inspectAttribute(resources, attrName, attrValue) { @@ -62,12 +67,19 @@ var TemplatingBindingLanguage = (function (_BindingLanguage) { info.attrName = parts[0].trim(); info.attrValue = attrValue; info.command = parts[1].trim(); - info.expression = null; + + if (info.command === 'ref') { + info.expression = new _aureliaBinding.NameExpression(attrValue, info.attrName); + info.command = null; + info.attrName = 'ref'; + } else { + info.expression = null; + } } else if (attrName == 'ref') { info.attrName = attrName; info.attrValue = attrValue; info.command = null; - info.expression = new _Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode.NameExpression(attrValue, 'element'); + info.expression = new _aureliaBinding.NameExpression(attrValue, 'element'); } else { info.attrName = attrName; info.attrValue = attrValue; @@ -168,11 +180,11 @@ var TemplatingBindingLanguage = (function (_BindingLanguage) { parts[partIndex] = attrValue.substr(pos); - return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode.bindingMode.oneWay, resources.valueConverterLookupFunction, attrName); + return new InterpolationBindingExpression(this.observerLocator, this.attributeMap[attrName] || attrName, parts, _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction, attrName); }; return TemplatingBindingLanguage; -})(_BindingLanguage2.BindingLanguage); +})(_aureliaTemplating.BindingLanguage); exports.TemplatingBindingLanguage = TemplatingBindingLanguage; @@ -222,7 +234,7 @@ var InterpolationBinding = (function () { InterpolationBinding.prototype.bind = function bind(source) { this.source = source; - if (this.mode == _Parser$ObserverLocator$BindingExpression$NameExpression$bindingMode.bindingMode.oneWay) { + if (this.mode == _aureliaBinding.bindingMode.oneWay) { this.unbind(); this.connect(); this.setValue(); diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 6c13f7a..66223c1 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -2,27 +2,27 @@ exports.__esModule = true; -var _BindingLanguage = require('aurelia-templating'); +var _aureliaTemplating = require('aurelia-templating'); -var _TemplatingBindingLanguage = require('./binding-language'); +var _bindingLanguage = require('./binding-language'); -var _SyntaxInterpreter = require('./syntax-interpreter'); +var _syntaxInterpreter = require('./syntax-interpreter'); function configure(aurelia) { var instance, getInstance = function getInstance(c) { - return instance || (instance = c.invoke(_TemplatingBindingLanguage.TemplatingBindingLanguage)); + return instance || (instance = c.invoke(_bindingLanguage.TemplatingBindingLanguage)); }; - if (aurelia.container.hasHandler(_TemplatingBindingLanguage.TemplatingBindingLanguage)) { - instance = aurelia.container.get(_TemplatingBindingLanguage.TemplatingBindingLanguage); + if (aurelia.container.hasHandler(_bindingLanguage.TemplatingBindingLanguage)) { + instance = aurelia.container.get(_bindingLanguage.TemplatingBindingLanguage); } else { - aurelia.container.registerHandler(_TemplatingBindingLanguage.TemplatingBindingLanguage, getInstance); + aurelia.container.registerHandler(_bindingLanguage.TemplatingBindingLanguage, getInstance); } - aurelia.container.registerHandler(_BindingLanguage.BindingLanguage, getInstance); + aurelia.container.registerHandler(_aureliaTemplating.BindingLanguage, getInstance); } -exports.TemplatingBindingLanguage = _TemplatingBindingLanguage.TemplatingBindingLanguage; -exports.SyntaxInterpreter = _SyntaxInterpreter.SyntaxInterpreter; +exports.TemplatingBindingLanguage = _bindingLanguage.TemplatingBindingLanguage; +exports.SyntaxInterpreter = _syntaxInterpreter.SyntaxInterpreter; exports.configure = configure; \ No newline at end of file diff --git a/dist/commonjs/syntax-interpreter.js b/dist/commonjs/syntax-interpreter.js index e46c2e7..73a7673 100644 --- a/dist/commonjs/syntax-interpreter.js +++ b/dist/commonjs/syntax-interpreter.js @@ -1,10 +1,10 @@ 'use strict'; -var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; - exports.__esModule = true; -var _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode = require('aurelia-binding'); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _aureliaBinding = require('aurelia-binding'); var SyntaxInterpreter = (function () { function SyntaxInterpreter(parser, observerLocator, eventManager) { @@ -16,7 +16,7 @@ var SyntaxInterpreter = (function () { } SyntaxInterpreter.inject = function inject() { - return [_Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.Parser, _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.ObserverLocator, _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.EventManager]; + return [_aureliaBinding.Parser, _aureliaBinding.ObserverLocator, _aureliaBinding.EventManager]; }; SyntaxInterpreter.prototype.interpret = function interpret(resources, element, info, existingInstruction) { @@ -45,36 +45,38 @@ var SyntaxInterpreter = (function () { var tagName = element.tagName.toLowerCase(); if (tagName === 'input') { - return attrName === 'value' || attrName === 'checked' ? _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.twoWay : _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.oneWay; + return attrName === 'value' || attrName === 'checked' ? _aureliaBinding.bindingMode.twoWay : _aureliaBinding.bindingMode.oneWay; } else if (tagName == 'textarea' || tagName == 'select') { - return attrName == 'value' ? _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.twoWay : _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.oneWay; + return attrName == 'value' ? _aureliaBinding.bindingMode.twoWay : _aureliaBinding.bindingMode.oneWay; } else if (attrName === 'textcontent' || attrName === 'innerhtml') { - return element.contentEditable === 'true' ? _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.twoWay : _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.oneWay; + return element.contentEditable === 'true' ? _aureliaBinding.bindingMode.twoWay : _aureliaBinding.bindingMode.oneWay; + } else if (attrName === 'scrolltop' || attrName === 'scrollleft') { + return _aureliaBinding.bindingMode.twoWay; } - return _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.oneWay; + return _aureliaBinding.bindingMode.oneWay; }; SyntaxInterpreter.prototype.bind = function bind(resources, element, info, existingInstruction) { var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - instruction.attributes[info.attrName] = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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.valueConverterLookupFunction); return instruction; }; SyntaxInterpreter.prototype.trigger = function trigger(resources, element, info) { - return new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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); }; SyntaxInterpreter.prototype.delegate = function delegate(resources, element, info) { - return new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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); }; SyntaxInterpreter.prototype.call = function call(resources, element, info, existingInstruction) { var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - instruction.attributes[info.attrName] = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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.valueConverterLookupFunction); return instruction; }; @@ -128,25 +130,26 @@ var SyntaxInterpreter = (function () { exports.SyntaxInterpreter = SyntaxInterpreter; SyntaxInterpreter.prototype['for'] = function (resources, element, info, existingInstruction) { - var parts = info.attrValue.split(' of '); + var parts, keyValue, instruction, attrValue, isDestructuring; + attrValue = info.attrValue; + isDestructuring = attrValue.match(/[[].+[\]]/); + parts = isDestructuring ? attrValue.split('of ') : attrValue.split(' of '); if (parts.length !== 2) { - throw new Error('Incorrect syntax for "for". The form is: "$local of $items".'); + throw new Error('Incorrect syntax for "for". The form is: "$local of $items" or "[$key, $value] of $items".'); } - var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; + instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - if (parts[0].match(/[[].+[,]\s.+[\]]/)) { - var firstPart = parts[0]; - parts[0] = firstPart.substr(1, firstPart.indexOf(',') - 1); - parts.splice(1, 0, firstPart.substring(firstPart.indexOf(', ') + 2, firstPart.length - 1)); - instruction.attributes.key = parts[0]; - instruction.attributes.value = parts[1]; + if (isDestructuring) { + keyValue = parts[0].replace(/[[\]]/g, '').replace(/,/g, ' ').replace(/\s+/g, ' ').trim().split(' '); + instruction.attributes.key = keyValue[0]; + instruction.attributes.value = keyValue[1]; } else { instruction.attributes.local = parts[0]; } - instruction.attributes.items = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[parts.length - 1]), _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new _aureliaBinding.BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), _aureliaBinding.bindingMode.oneWay, resources.valueConverterLookupFunction); return instruction; }; @@ -154,7 +157,7 @@ SyntaxInterpreter.prototype['for'] = function (resources, element, info, existin SyntaxInterpreter.prototype['two-way'] = function (resources, element, info, existingInstruction) { var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - instruction.attributes[info.attrName] = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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.valueConverterLookupFunction); return instruction; }; @@ -162,7 +165,7 @@ SyntaxInterpreter.prototype['two-way'] = function (resources, element, info, exi SyntaxInterpreter.prototype['one-way'] = function (resources, element, info, existingInstruction) { var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - instruction.attributes[info.attrName] = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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.valueConverterLookupFunction); return instruction; }; @@ -170,11 +173,7 @@ SyntaxInterpreter.prototype['one-way'] = function (resources, element, info, exi SyntaxInterpreter.prototype['one-time'] = function (resources, element, info, existingInstruction) { var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - instruction.attributes[info.attrName] = new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.BindingExpression(this.observerLocator, this.attributeMap[info.attrName] || info.attrName, this.parser.parse(info.attrValue), _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.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.valueConverterLookupFunction); return instruction; -}; - -SyntaxInterpreter.prototype['view-model'] = function (resources, element, info) { - return new _Parser$ObserverLocator$EventManager$ListenerExpression$BindingExpression$NameExpression$CallExpression$bindingMode.NameExpression(info.attrValue, 'view-model'); }; \ No newline at end of file diff --git a/dist/es6/binding-language.js b/dist/es6/binding-language.js index 0fba5c4..d8f8a23 100644 --- a/dist/es6/binding-language.js +++ b/dist/es6/binding-language.js @@ -16,7 +16,6 @@ export class TemplatingBindingLanguage extends BindingLanguage { this.emptyStringExpression = this.parser.parse('\'\''); syntaxInterpreter.language = this; this.attributeMap = syntaxInterpreter.attributeMap = { - 'class':'className', 'contenteditable':'contentEditable', 'for':'htmlFor', 'tabindex':'tabIndex', @@ -30,6 +29,10 @@ export class TemplatingBindingLanguage extends BindingLanguage { 'formmethod':'formMethod', 'formnovalidate':'formNoValidate', 'formtarget':'formTarget', + 'rowspan':'rowSpan', + 'colspan':'colSpan', + 'scrolltop':'scrollTop', + 'scrollleft':'scrollLeft' }; } @@ -42,7 +45,14 @@ export class TemplatingBindingLanguage extends BindingLanguage { info.attrName = parts[0].trim(); info.attrValue = attrValue; info.command = parts[1].trim(); - info.expression = null; + + if(info.command === 'ref'){ + info.expression = new NameExpression(attrValue, info.attrName); + info.command = null; + info.attrName = 'ref'; + } else{ + info.expression = null; + } }else if(attrName == 'ref'){ info.attrName = attrName; info.attrValue = attrValue; diff --git a/dist/es6/syntax-interpreter.js b/dist/es6/syntax-interpreter.js index 13c9a37..36fd549 100644 --- a/dist/es6/syntax-interpreter.js +++ b/dist/es6/syntax-interpreter.js @@ -48,6 +48,8 @@ export class SyntaxInterpreter { return attrName == 'value' ? bindingMode.twoWay : bindingMode.oneWay; }else if(attrName === 'textcontent' || attrName === 'innerhtml'){ return element.contentEditable === 'true' ? bindingMode.twoWay : bindingMode.oneWay; + } else if(attrName === 'scrolltop' || attrName === 'scrollleft'){ + return bindingMode.twoWay; } return bindingMode.oneWay; @@ -141,31 +143,32 @@ export class SyntaxInterpreter { } SyntaxInterpreter.prototype['for'] = function(resources, element, info, existingInstruction){ - var parts = info.attrValue.split(' of '); + var parts, keyValue, instruction, attrValue, isDestructuring; + attrValue = info.attrValue; + isDestructuring = attrValue.match(/[[].+[\]]/); + parts = isDestructuring ? attrValue.split('of ') : attrValue.split(' of '); if(parts.length !== 2){ - throw new Error('Incorrect syntax for "for". The form is: "$local of $items".'); + throw new Error('Incorrect syntax for "for". The form is: "$local of $items" or "[$key, $value] of $items".'); } - var instruction = existingInstruction || {attrName:info.attrName, attributes:{}}; + instruction = existingInstruction || {attrName:info.attrName, attributes:{}}; - if(parts[0].match(/[[].+[,]\s.+[\]]/)){ - var firstPart = parts[0]; - parts[0] = firstPart.substr(1, firstPart.indexOf(',') - 1); - parts.splice(1, 0, firstPart.substring(firstPart.indexOf(', ') + 2, firstPart.length -1)); - instruction.attributes.key = parts[0]; - instruction.attributes.value = parts[1]; + if(isDestructuring){ + keyValue = parts[0].replace(/[[\]]/g, '').replace(/,/g, ' ').replace(/\s+/g, ' ').trim().split(' '); + instruction.attributes.key = keyValue[0]; + instruction.attributes.value = keyValue[1]; }else{ instruction.attributes.local = parts[0]; } instruction.attributes.items = new BindingExpression( - this.observerLocator, - 'items', - this.parser.parse(parts[parts.length - 1]), - bindingMode.oneWay, - resources.valueConverterLookupFunction - ); + this.observerLocator, + 'items', + this.parser.parse(parts[1]), + bindingMode.oneWay, + resources.valueConverterLookupFunction + ); return instruction; }; @@ -211,7 +214,3 @@ SyntaxInterpreter.prototype['one-time'] = function(resources, element, info, exi return instruction; }; - -SyntaxInterpreter.prototype["view-model"] = function (resources, element, info) { - return new NameExpression(info.attrValue, 'view-model'); -}; diff --git a/dist/system/binding-language.js b/dist/system/binding-language.js index 4296a47..11b52c2 100644 --- a/dist/system/binding-language.js +++ b/dist/system/binding-language.js @@ -1,5 +1,11 @@ System.register(['aurelia-templating', 'aurelia-binding', './syntax-interpreter', 'aurelia-logging'], function (_export) { - var BindingLanguage, Parser, ObserverLocator, BindingExpression, NameExpression, bindingMode, SyntaxInterpreter, LogManager, _classCallCheck, _inherits, info, logger, TemplatingBindingLanguage, InterpolationBindingExpression, InterpolationBinding; + 'use strict'; + + var BindingLanguage, Parser, ObserverLocator, BindingExpression, NameExpression, bindingMode, SyntaxInterpreter, LogManager, info, logger, TemplatingBindingLanguage, InterpolationBindingExpression, InterpolationBinding; + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } return { setters: [function (_aureliaTemplating) { @@ -16,12 +22,6 @@ System.register(['aurelia-templating', 'aurelia-binding', './syntax-interpreter' LogManager = _aureliaLogging; }], execute: function () { - 'use strict'; - - _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; - - _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; - info = {}; logger = LogManager.getLogger('templating-binding'); @@ -36,19 +36,24 @@ System.register(['aurelia-templating', 'aurelia-binding', './syntax-interpreter' this.emptyStringExpression = this.parser.parse('\'\''); syntaxInterpreter.language = this; this.attributeMap = syntaxInterpreter.attributeMap = { - 'class': 'className', - contenteditable: 'contentEditable', + 'contenteditable': 'contentEditable', 'for': 'htmlFor', - tabindex: 'tabIndex', - textcontent: 'textContent', - innerhtml: 'innerHTML', - maxlength: 'maxLength', - minlength: 'minLength', - formaction: 'formAction', - formenctype: 'formEncType', - formmethod: 'formMethod', - formnovalidate: 'formNoValidate', - formtarget: 'formTarget' }; + 'tabindex': 'tabIndex', + 'textcontent': 'textContent', + 'innerhtml': 'innerHTML', + + 'maxlength': 'maxLength', + 'minlength': 'minLength', + 'formaction': 'formAction', + 'formenctype': 'formEncType', + 'formmethod': 'formMethod', + 'formnovalidate': 'formNoValidate', + 'formtarget': 'formTarget', + 'rowspan': 'rowSpan', + 'colspan': 'colSpan', + 'scrolltop': 'scrollTop', + 'scrollleft': 'scrollLeft' + }; } _inherits(TemplatingBindingLanguage, _BindingLanguage); @@ -66,7 +71,14 @@ System.register(['aurelia-templating', 'aurelia-binding', './syntax-interpreter' info.attrName = parts[0].trim(); info.attrValue = attrValue; info.command = parts[1].trim(); - info.expression = null; + + if (info.command === 'ref') { + info.expression = new NameExpression(attrValue, info.attrName); + info.command = null; + info.attrName = 'ref'; + } else { + info.expression = null; + } } else if (attrName == 'ref') { info.attrName = attrName; info.attrValue = attrValue; diff --git a/dist/system/index.js b/dist/system/index.js index c80b3b3..2fa3790 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,4 +1,6 @@ System.register(['aurelia-templating', './binding-language', './syntax-interpreter'], function (_export) { + 'use strict'; + var BindingLanguage, TemplatingBindingLanguage, SyntaxInterpreter; function configure(aurelia) { @@ -25,8 +27,6 @@ System.register(['aurelia-templating', './binding-language', './syntax-interpret SyntaxInterpreter = _syntaxInterpreter.SyntaxInterpreter; }], execute: function () { - 'use strict'; - _export('TemplatingBindingLanguage', TemplatingBindingLanguage); _export('SyntaxInterpreter', SyntaxInterpreter); diff --git a/dist/system/syntax-interpreter.js b/dist/system/syntax-interpreter.js index c34066c..9732ba3 100644 --- a/dist/system/syntax-interpreter.js +++ b/dist/system/syntax-interpreter.js @@ -1,5 +1,9 @@ System.register(['aurelia-binding'], function (_export) { - var Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, NameExpression, CallExpression, bindingMode, _classCallCheck, SyntaxInterpreter; + 'use strict'; + + var Parser, ObserverLocator, EventManager, ListenerExpression, BindingExpression, NameExpression, CallExpression, bindingMode, SyntaxInterpreter; + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } return { setters: [function (_aureliaBinding) { @@ -13,10 +17,6 @@ System.register(['aurelia-binding'], function (_export) { bindingMode = _aureliaBinding.bindingMode; }], execute: function () { - 'use strict'; - - _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; - SyntaxInterpreter = (function () { function SyntaxInterpreter(parser, observerLocator, eventManager) { _classCallCheck(this, SyntaxInterpreter); @@ -61,6 +61,8 @@ System.register(['aurelia-binding'], function (_export) { return attrName == 'value' ? bindingMode.twoWay : bindingMode.oneWay; } else if (attrName === 'textcontent' || attrName === 'innerhtml') { return element.contentEditable === 'true' ? bindingMode.twoWay : bindingMode.oneWay; + } else if (attrName === 'scrolltop' || attrName === 'scrollleft') { + return bindingMode.twoWay; } return bindingMode.oneWay; @@ -139,25 +141,26 @@ System.register(['aurelia-binding'], function (_export) { _export('SyntaxInterpreter', SyntaxInterpreter); SyntaxInterpreter.prototype['for'] = function (resources, element, info, existingInstruction) { - var parts = info.attrValue.split(' of '); + var parts, keyValue, instruction, attrValue, isDestructuring; + attrValue = info.attrValue; + isDestructuring = attrValue.match(/[[].+[\]]/); + parts = isDestructuring ? attrValue.split('of ') : attrValue.split(' of '); if (parts.length !== 2) { - throw new Error('Incorrect syntax for "for". The form is: "$local of $items".'); + throw new Error('Incorrect syntax for "for". The form is: "$local of $items" or "[$key, $value] of $items".'); } - var instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; + instruction = existingInstruction || { attrName: info.attrName, attributes: {} }; - if (parts[0].match(/[[].+[,]\s.+[\]]/)) { - var firstPart = parts[0]; - parts[0] = firstPart.substr(1, firstPart.indexOf(',') - 1); - parts.splice(1, 0, firstPart.substring(firstPart.indexOf(', ') + 2, firstPart.length - 1)); - instruction.attributes.key = parts[0]; - instruction.attributes.value = parts[1]; + if (isDestructuring) { + keyValue = parts[0].replace(/[[\]]/g, '').replace(/,/g, ' ').replace(/\s+/g, ' ').trim().split(' '); + instruction.attributes.key = keyValue[0]; + instruction.attributes.value = keyValue[1]; } else { instruction.attributes.local = parts[0]; } - instruction.attributes.items = new BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[parts.length - 1]), bindingMode.oneWay, resources.valueConverterLookupFunction); + instruction.attributes.items = new BindingExpression(this.observerLocator, 'items', this.parser.parse(parts[1]), bindingMode.oneWay, resources.valueConverterLookupFunction); return instruction; }; @@ -185,10 +188,6 @@ System.register(['aurelia-binding'], function (_export) { return instruction; }; - - SyntaxInterpreter.prototype['view-model'] = function (resources, element, info) { - return new NameExpression(info.attrValue, 'view-model'); - }; } }; }); \ No newline at end of file diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 83a3dd3..bea1b88 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,19 @@ +## 0.12.0 (2015-06-08) + + +#### Bug Fixes + +* **attribute-map:** add rowspan and colspan attributes ([eb8667a3](http://github.com/aurelia/templating-binding/commit/eb8667a3e8c420d4f271e4d5f9fee17c2180b489)) +* **attributeMap:** do not remap style ([1813f392](http://github.com/aurelia/templating-binding/commit/1813f392477e5f7588bf164fc4bf6d03ddefdeea)) +* **syntax-interpeter:** destructuring syntax in for parses incorrectly ([87c735aa](http://github.com/aurelia/templating-binding/commit/87c735aa19974a1239c561417536200f2634a63f), closes [#36](http://github.com/aurelia/templating-binding/issues/36)) + + +#### Features + +* **all:** make ref bindings work with api properties ([9541e397](http://github.com/aurelia/templating-binding/commit/9541e3972dc088607bb59cfcff9c703ebb19a6c4)) +* **attributeMap:** scrollTop/scrollLeft binding ([26220cc9](http://github.com/aurelia/templating-binding/commit/26220cc9c9b179f46b621481cb317a0ab0a9c593)) + + ## 0.11.0 (2015-04-30) diff --git a/package.json b/package.json index 1b2fe2c..c5005a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating-binding", - "version": "0.11.0", + "version": "0.12.0", "description": "An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.", "keywords": [ "aurelia", @@ -26,9 +26,9 @@ "lib": "dist/system" }, "dependencies": { - "aurelia-binding": "github:aurelia/binding@^0.6.0", - "aurelia-logging": "github:aurelia/logging@^0.4.0", - "aurelia-templating": "github:aurelia/templating@^0.11.0" + "aurelia-binding": "github:aurelia/binding@^0.7.0", + "aurelia-logging": "github:aurelia/logging@^0.5.0", + "aurelia-templating": "github:aurelia/templating@^0.12.0" }, "devDependencies": { "babel": "npm:babel-core@^5.1.13",