diff --git a/bower.json b/bower.json index fccd0e67..a5bdae9a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating", - "version": "0.12.0", + "version": "0.12.1", "description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.", "keywords": [ "aurelia", diff --git a/dist/amd/html-behavior.js b/dist/amd/html-behavior.js index ddaa9ed8..25e2f499 100644 --- a/dist/amd/html-behavior.js +++ b/dist/amd/html-behavior.js @@ -62,7 +62,8 @@ define(['exports', 'aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', this.handlesUnbind = 'unbind' in proto; this.handlesAttached = 'attached' in proto; this.handlesDetached = 'detached' in proto; - this.apiName = (this.elementName || this.attributeName).replace(/-([a-z])/g, function (m, w) { + this.htmlName = this.elementName || this.attributeName; + this.apiName = this.htmlName.replace(/-([a-z])/g, function (m, w) { return w.toUpperCase(); }); @@ -229,7 +230,7 @@ define(['exports', 'aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', viewFactory = instruction.viewFactory || this.viewFactory; if (viewFactory) { - behaviorInstance.view = viewFactory.create(container, behaviorInstance.executionContext, instruction); + behaviorInstance.view = viewFactory.create(container, executionContext, instruction); } if (element) { @@ -256,7 +257,7 @@ define(['exports', 'aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', if (instruction.anchorIsContainer) { if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(host, executionContext)); } behaviorInstance.view.appendNodesTo(host); @@ -264,23 +265,29 @@ define(['exports', 'aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', behaviorInstance.view.insertNodesBefore(host); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } } else if (behaviorInstance.view) { behaviorInstance.view.owner = behaviorInstance; if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } - if (element && !(this.apiName in element)) { - element[this.apiName] = behaviorInstance.executionContext; + if (element) { + if (!(this.apiName in element)) { + element[this.apiName] = executionContext; + } + + if (!(this.htmlName in element)) { + element[this.htmlName] = behaviorInstance; + } } return behaviorInstance; diff --git a/dist/commonjs/html-behavior.js b/dist/commonjs/html-behavior.js index 8acc311d..91caabee 100644 --- a/dist/commonjs/html-behavior.js +++ b/dist/commonjs/html-behavior.js @@ -79,7 +79,8 @@ var HtmlBehaviorResource = (function () { this.handlesUnbind = 'unbind' in proto; this.handlesAttached = 'attached' in proto; this.handlesDetached = 'detached' in proto; - this.apiName = (this.elementName || this.attributeName).replace(/-([a-z])/g, function (m, w) { + this.htmlName = this.elementName || this.attributeName; + this.apiName = this.htmlName.replace(/-([a-z])/g, function (m, w) { return w.toUpperCase(); }); @@ -246,7 +247,7 @@ var HtmlBehaviorResource = (function () { viewFactory = instruction.viewFactory || this.viewFactory; if (viewFactory) { - behaviorInstance.view = viewFactory.create(container, behaviorInstance.executionContext, instruction); + behaviorInstance.view = viewFactory.create(container, executionContext, instruction); } if (element) { @@ -273,7 +274,7 @@ var HtmlBehaviorResource = (function () { if (instruction.anchorIsContainer) { if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(host, executionContext)); } behaviorInstance.view.appendNodesTo(host); @@ -281,23 +282,29 @@ var HtmlBehaviorResource = (function () { behaviorInstance.view.insertNodesBefore(host); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } } else if (behaviorInstance.view) { behaviorInstance.view.owner = behaviorInstance; if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } - if (element && !(this.apiName in element)) { - element[this.apiName] = behaviorInstance.executionContext; + if (element) { + if (!(this.apiName in element)) { + element[this.apiName] = executionContext; + } + + if (!(this.htmlName in element)) { + element[this.htmlName] = behaviorInstance; + } } return behaviorInstance; diff --git a/dist/es6/html-behavior.js b/dist/es6/html-behavior.js index 819ffc82..b00b0945 100644 --- a/dist/es6/html-behavior.js +++ b/dist/es6/html-behavior.js @@ -61,7 +61,8 @@ export class HtmlBehaviorResource { this.handlesUnbind = ('unbind' in proto); this.handlesAttached = ('attached' in proto); this.handlesDetached = ('detached' in proto); - this.apiName = (this.elementName || this.attributeName).replace(/-([a-z])/g, (m, w) => w.toUpperCase()); + this.htmlName = this.elementName || this.attributeName; + this.apiName = this.htmlName.replace(/-([a-z])/g, (m, w) => w.toUpperCase()); if(attributeName !== null){ if(properties.length === 0){ //default for custom attributes @@ -223,8 +224,8 @@ export class HtmlBehaviorResource { viewFactory = instruction.viewFactory || this.viewFactory; if(viewFactory){ - //TODO: apply element instructions? var results = viewFactory.applyElementInstructions(container, behaviorInstance.executionContext, element); - behaviorInstance.view = viewFactory.create(container, behaviorInstance.executionContext, instruction); + //TODO: apply element instructions? var results = viewFactory.applyElementInstructions(container, executionContext, element); + behaviorInstance.view = viewFactory.create(container, executionContext, instruction); //TODO: register results with view } @@ -254,7 +255,7 @@ export class HtmlBehaviorResource { if(instruction.anchorIsContainer){ if(this.childExpression){ - behaviorInstance.view.addBinding(this.childExpression.createBinding(host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(host, executionContext)); } behaviorInstance.view.appendNodesTo(host); @@ -262,26 +263,32 @@ export class HtmlBehaviorResource { behaviorInstance.view.insertNodesBefore(host); } }else if(this.childExpression){ - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } }else if(behaviorInstance.view){ //dynamic element with view behaviorInstance.view.owner = behaviorInstance; if(this.childExpression){ - behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, executionContext)); } }else if(this.childExpression){ //dynamic element without view - bindings.push(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(instruction.host, executionContext)); } } else if(this.childExpression){ //custom attribute - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } - if(element && !(this.apiName in element)){ - element[this.apiName] = behaviorInstance.executionContext; + if(element){ + if(!(this.apiName in element)){ + element[this.apiName] = executionContext; + } + + if(!(this.htmlName in element)){ + element[this.htmlName] = behaviorInstance; + } } return behaviorInstance; diff --git a/dist/system/html-behavior.js b/dist/system/html-behavior.js index b5cb18c0..33e23dcb 100644 --- a/dist/system/html-behavior.js +++ b/dist/system/html-behavior.js @@ -83,7 +83,8 @@ System.register(['aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', '. this.handlesUnbind = 'unbind' in proto; this.handlesAttached = 'attached' in proto; this.handlesDetached = 'detached' in proto; - this.apiName = (this.elementName || this.attributeName).replace(/-([a-z])/g, function (m, w) { + this.htmlName = this.elementName || this.attributeName; + this.apiName = this.htmlName.replace(/-([a-z])/g, function (m, w) { return w.toUpperCase(); }); @@ -250,7 +251,7 @@ System.register(['aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', '. viewFactory = instruction.viewFactory || this.viewFactory; if (viewFactory) { - behaviorInstance.view = viewFactory.create(container, behaviorInstance.executionContext, instruction); + behaviorInstance.view = viewFactory.create(container, executionContext, instruction); } if (element) { @@ -277,7 +278,7 @@ System.register(['aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', '. if (instruction.anchorIsContainer) { if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(host, executionContext)); } behaviorInstance.view.appendNodesTo(host); @@ -285,23 +286,29 @@ System.register(['aurelia-metadata', 'aurelia-binding', 'aurelia-task-queue', '. behaviorInstance.view.insertNodesBefore(host); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } } else if (behaviorInstance.view) { behaviorInstance.view.owner = behaviorInstance; if (this.childExpression) { - behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + behaviorInstance.view.addBinding(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(instruction.host, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(instruction.host, executionContext)); } } else if (this.childExpression) { - bindings.push(this.childExpression.createBinding(element, behaviorInstance.executionContext)); + bindings.push(this.childExpression.createBinding(element, executionContext)); } - if (element && !(this.apiName in element)) { - element[this.apiName] = behaviorInstance.executionContext; + if (element) { + if (!(this.apiName in element)) { + element[this.apiName] = executionContext; + } + + if (!(this.htmlName in element)) { + element[this.htmlName] = behaviorInstance; + } } return behaviorInstance; diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index a40daff2..55ae14ed 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,11 @@ +### 0.12.1 (2015-06-09) + + +#### Bug Fixes + +* **html-behavior:** add htmlName to element with behavior instance reference ([6e224d78](http://github.com/aurelia/templating/commit/6e224d785306c818143c6aab4589717862c154f8)) + + ## 0.12.0 (2015-06-08) diff --git a/package.json b/package.json index 535a0deb..c505b4ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-templating", - "version": "0.12.0", + "version": "0.12.1", "description": "An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.", "keywords": [ "aurelia", diff --git a/src/html-behavior.js b/src/html-behavior.js index 7ab47f37..b00b0945 100644 --- a/src/html-behavior.js +++ b/src/html-behavior.js @@ -282,11 +282,11 @@ export class HtmlBehaviorResource { } if(element){ - if(!(this.apiName in element){ + if(!(this.apiName in element)){ element[this.apiName] = executionContext; } - if(!(this.htmlName in element){ + if(!(this.htmlName in element)){ element[this.htmlName] = behaviorInstance; } }