Skip to content

Commit

Permalink
See knockout#375. Allow spaces around "=" in data-bind attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mbest committed May 14, 2013
1 parent 15da151 commit 86a62bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/templatingBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ describe('Templating', function() {
expect(testNode.childNodes[0].value).toEqual("hello");
});

it('Should handle data-bind attributes with spaces around equals sign from inside templates and reference variables', function () {
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: "<input data-bind = 'value:message' />" }));
ko.renderTemplate("someTemplate", null, { templateRenderingVariablesInScope: { message: "hello"} }, testNode);
expect(testNode.childNodes[0].value).toEqual("hello");
});

it('Data binding syntax should be able to use $element in binding value', function() {
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: "<div data-bind='text: $element.tagName'></div>" }));
ko.renderTemplate("someTemplate", null, null, testNode);
Expand Down
2 changes: 1 addition & 1 deletion src/templating/templateRewriting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

ko.templateRewriting = (function () {
var memoizeDataBindingAttributeSyntaxRegex = /(<([a-z]+\d*)(?:\s+(?!data-bind=)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind=(["'])([\s\S]*?)\3/gi;
var memoizeDataBindingAttributeSyntaxRegex = /(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi;
var memoizeVirtualContainerBindingSyntaxRegex = /<!--\s*ko\b\s*([\s\S]*?)\s*-->/g;

function validateDataBindValuesForRewriting(keyValueArray) {
Expand Down

0 comments on commit 86a62bd

Please sign in to comment.