Skip to content

Commit

Permalink
fix references to createChildContextWithAs in specs. see knockout#2403
Browse files Browse the repository at this point in the history
  • Loading branch information
mbest committed Sep 11, 2018
1 parent 3281f73 commit ad2752e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
5 changes: 0 additions & 5 deletions spec/defaultBindings/foreachBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,6 @@ describe('Binding: Foreach', function() {
}

describe('With "noChildContext = true" and "as"', function () {
beforeEach(function() {
this.restoreAfter(ko.options, 'createChildContextWithAs');
ko.options.createChildContextWithAs = false;
});

it('Should not create a child context', function () {
testNode.innerHTML = "<div data-bind='foreach: { data: someItems, as: \"item\", noChildContext: true }'><span data-bind='text: item'></span></div>";
var someItems = ['alpha', 'beta'];
Expand Down
22 changes: 6 additions & 16 deletions spec/templatingBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1179,17 +1179,12 @@ describe('Templating', function() {
expect(testDocFrag.childNodes[0]).toContainHtml("myval: 123");
});

describe('With "createChildContextWithAs = false" and "as"', function () {
beforeEach(function() {
this.restoreAfter(ko.options, 'createChildContextWithAs');
ko.options.createChildContextWithAs = false;
});

describe('With "noChildContext = true" and "as"', function () {
it('Should bind viewmodel to an alias', function() {
ko.setTemplateEngine(new dummyTemplateEngine({
myTemplate: "ValueLiteral: [js:item.prop], ValueBound: <span data-bind='text: item.prop'></span>"
}));
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\" }'></div>";
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", noChildContext: true }'></div>";
ko.applyBindings({ someItem: { prop: 'Hello' } }, testNode);
expect(testNode.childNodes[0]).toContainText("ValueLiteral: Hello, ValueBound: Hello");
});
Expand All @@ -1203,23 +1198,18 @@ describe('Templating', function() {
ko.setTemplateEngine(new dummyTemplateEngine({
myTemplate: "ValueLiteral: [js:item.prop], ValueBound: <span data-bind='text: item.prop'></span>"
}));
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", afterRender: callback }'></div>";
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", noChildContext: true, afterRender: callback }'></div>";
ko.applyBindings({ someItem: myModel, callback: myCallback }, testNode);
expect(passedDataItem).toEqual(myModel);
});
});

describe('With "createChildContextWithAs = true" and "as"', function () {
beforeEach(function() {
this.restoreAfter(ko.options, 'createChildContextWithAs');
ko.options.createChildContextWithAs = true;
});

describe('With "noChildContext = false" and "as"', function () {
it('Should bind viewmodel to an alias', function() {
ko.setTemplateEngine(new dummyTemplateEngine({
myTemplate: "ValueLiteral: [js:item.prop], ValueBound: <span data-bind='text: item.prop'></span>"
}));
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\" }'></div>";
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", noChildContext: false }'></div>";
ko.applyBindings({ someItem: { prop: 'Hello' } }, testNode);
expect(testNode.childNodes[0]).toContainText("ValueLiteral: Hello, ValueBound: Hello");
});
Expand All @@ -1233,7 +1223,7 @@ describe('Templating', function() {
ko.setTemplateEngine(new dummyTemplateEngine({
myTemplate: "ValueLiteral: [js:item.prop], ValueBound: <span data-bind='text: item.prop'></span>"
}));
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", afterRender: callback }'></div>";
testNode.innerHTML = "<div data-bind='template: { name: \"myTemplate\", data: someItem, as: \"item\", noChildContext: false, afterRender: callback }'></div>";
ko.applyBindings({ someItem: myModel, callback: myCallback }, testNode);
expect(passedDataItem).toEqual(myModel);
});
Expand Down

0 comments on commit ad2752e

Please sign in to comment.