From 4553a4c2bbc322bfc2346b46d000870f4365e86e Mon Sep 17 00:00:00 2001 From: Offir Golan Date: Tue, 13 Oct 2015 10:51:03 -0700 Subject: [PATCH] Support v-get inside element note attribute strings Bugfix for #53 --- README.md | 2 +- docs/docs/index.md | 2 +- htmlbars-plugins/v-get.js | 12 ++++++++++-- tests/integration/helpers/v-get-test.js | 9 +++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4134f0a2..d08966e1 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ import User from '../models/user'; export default Ember.Route.extend({ model() { var container = this.get('container'); - return User.create({ container }) + return User.create({ username: 'John', container }) } }); ``` diff --git a/docs/docs/index.md b/docs/docs/index.md index 9cb6924c..38ccc498 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -97,7 +97,7 @@ import User from '../models/user'; export default Ember.Route.extend({ model() { var container = this.get('container'); - return User.create({ container }) + return User.create({ username: 'John', container }) } }); ``` diff --git a/htmlbars-plugins/v-get.js b/htmlbars-plugins/v-get.js index 12b79324..256f98b4 100644 --- a/htmlbars-plugins/v-get.js +++ b/htmlbars-plugins/v-get.js @@ -73,16 +73,24 @@ VGet.prototype.processNodeHash = function(node) { }; /** - * + * (node.attributes) + *
* @param {AST.Node} node */ VGet.prototype.processNodeAttributes = function(node) { + var i; if (node.attributes) { - for (var i = 0; i < node.attributes.length; i++) { + for (i = 0; i < node.attributes.length; i++) { var attr = node.attributes[i]; this.processNode(attr.value); } } + + if (node.parts) { + for (i = 0; i < node.parts.length; i++) { + this.processNode(node.parts[i]); + } + } }; diff --git a/tests/integration/helpers/v-get-test.js b/tests/integration/helpers/v-get-test.js index ac459785..2d11ea6c 100644 --- a/tests/integration/helpers/v-get-test.js +++ b/tests/integration/helpers/v-get-test.js @@ -86,3 +86,12 @@ test('element node attribute', function(assert) { assert.equal(this.$().text().trim(), 'Button'); assert.equal(this.$('button').prop('disabled'), true); }); + +test('element node attribute in class string', function(assert) { + assert.expect(3); + + this.render(hbs`Text`); + assert.equal(this.$().text().trim(), 'Text'); + assert.equal(this.$('span').hasClass('base'), true, 'base class present'); + assert.equal(this.$('span').hasClass('has-error'), true, 'error class present'); +});