Skip to content

Commit

Permalink
Remove whitespace from all blank lines, to match the new project stan…
Browse files Browse the repository at this point in the history
…dard
  • Loading branch information
SteveSanderson committed Apr 14, 2012
1 parent 82e541b commit cbfc4b9
Show file tree
Hide file tree
Showing 35 changed files with 463 additions and 463 deletions.
2 changes: 1 addition & 1 deletion spec/asyncBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ asyncTest("Should notify subscribers asynchronously after writes stop for the sp
observable('C');
observable('D');
equal(notifiedValues.length, 0, "Should not notify synchronously");

// Wait
stop();
setTimeout(function() {
Expand Down
54 changes: 27 additions & 27 deletions spec/bindingAttributeBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Binding attribute syntax', {
testNode.id = "testNode";
document.body.appendChild(testNode);
},

'applyBindings should accept no parameters and then act on document.body with undefined model': function() {
var didInit = false;
ko.bindingHandlers.test = {
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('Binding attribute syntax', {
// Just to avoid interfering with other specs:
ko.utils.domData.clear(document.body);
},

'applyBindings should accept two parameters and then act on second param as DOM node with first param as model': function() {
var didInit = false;
var suppliedViewModel = {};
Expand Down Expand Up @@ -129,24 +129,24 @@ describe('Binding attribute syntax', {
var observable = new ko.observable("A");
testNode.innerHTML = "<div data-bind='anyHandler: myObservable()'></div>";
ko.applyBindings({ myObservable: observable }, testNode);

value_of(observable.getSubscriptionsCount()).should_be(1);

ko.removeNode(testNode);

value_of(observable.getSubscriptionsCount()).should_be(0);
},

'If the associated DOM element was removed independently of KO, handler subscriptions are disposed on the next evaluation': function () {
var observable = new ko.observable("A");
testNode.innerHTML = "<div data-bind='anyHandler: myObservable()'></div>";
ko.applyBindings({ myObservable: observable }, testNode);

value_of(observable.getSubscriptionsCount()).should_be(1);

testNode.parentNode.removeChild(testNode);
observable("B"); // Force re-evaluation

value_of(observable.getSubscriptionsCount()).should_be(0);
},

Expand All @@ -164,13 +164,13 @@ describe('Binding attribute syntax', {
value_of(passedValues.length).should_be(2);
value_of(passedValues[1]).should_be("goodbye");
},

'Should be able to refer to the bound object itself (at the root scope, the viewmodel) via $data': function() {
testNode.innerHTML = "<div data-bind='text: $data.someProp'></div>";
ko.applyBindings({ someProp: 'My prop value' }, testNode);
value_of(testNode).should_contain_text("My prop value");
},

'Bindings can signal that they control descendant bindings by returning a flag from their init function': function() {
ko.bindingHandlers.test = {
init: function() { return { controlsDescendantBindings : true } }
Expand All @@ -180,24 +180,24 @@ describe('Binding attribute syntax', {
+ "</div>"
+ "<div data-bind='text: 123'>456</div>";
ko.applyBindings(null, testNode);

value_of(testNode.childNodes[0].childNodes[0].innerHTML).should_be("456");
value_of(testNode.childNodes[1].innerHTML).should_be("123");
},

'Should not be allowed to have multiple bindings on the same element that claim to control descendant bindings': function() {
ko.bindingHandlers.test1 = {
init: function() { return { controlsDescendantBindings : true } }
};
ko.bindingHandlers.test2 = ko.bindingHandlers.test1;
testNode.innerHTML = "<div data-bind='test1: true, test2: true'></div>"
var didThrow = false;

try { ko.applyBindings(null, testNode) }
catch(ex) { didThrow = true; value_of(ex.message).should_contain('Multiple bindings (test1 and test2) are trying to control descendant bindings of the same element.') }
value_of(didThrow).should_be(true);
},

'Should use properties on the view model in preference to properties on the binding context': function() {
testNode.innerHTML = "<div data-bind='text: $data.someProp'></div>";
ko.applyBindings({ '$data': { someProp: 'Inner value'}, someProp: 'Outer value' }, testNode);
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Binding attribute syntax', {
ko.applyBindings(null, testNode);
value_of(testNode).should_contain_text("my value");
},

'Should be able to retrieve the binding context associated with any node': function() {
testNode.innerHTML = "<div><div data-bind='text: name'></div></div>";
ko.applyBindings({ name: 'Bert' }, testNode.childNodes[0]);
Expand All @@ -248,7 +248,7 @@ describe('Binding attribute syntax', {
value_of(ko.dataFor(testNode.childNodes[0].childNodes[0]).name).should_be("Bert");
value_of(ko.contextFor(testNode.childNodes[0].childNodes[0]).$data.name).should_be("Bert");
},

'Should not be allowed to use containerless binding syntax for bindings other than whitelisted ones': function() {
testNode.innerHTML = "Hello <!-- ko visible: false -->Some text<!-- /ko --> Goodbye"
var didThrow = false;
Expand All @@ -260,7 +260,7 @@ describe('Binding attribute syntax', {
}
value_of(didThrow).should_be(true);
},

'Should be able to set a custom binding to use containerless binding': function() {
var initCalls = 0;
ko.bindingHandlers.test = { init: function () { initCalls++ } };
Expand All @@ -272,7 +272,7 @@ describe('Binding attribute syntax', {
value_of(initCalls).should_be(1);
value_of(testNode).should_contain_text("Hello Some text Goodbye");
},

'Should be able to access virtual children in custom containerless binding': function() {
var countNodes = 0;
ko.bindingHandlers.test = {
Expand All @@ -286,19 +286,19 @@ describe('Binding attribute syntax', {
}
};
ko.virtualElements.allowedBindings['test'] = true;

testNode.innerHTML = "Hello <!-- ko test: false -->Some text<!-- /ko --> Goodbye"
ko.applyBindings(null, testNode);

value_of(countNodes).should_be(1);
value_of(testNode).should_contain_text("Hello new text Goodbye");
},

'Should only bind containerless binding once inside template': function() {
var initCalls = 0;
ko.bindingHandlers.test = { init: function () { initCalls++ } };
ko.virtualElements.allowedBindings['test'] = true;

testNode.innerHTML = "Hello <!-- if: true --><!-- ko test: false -->Some text<!-- /ko --><!-- /ko --> Goodbye"
ko.applyBindings(null, testNode);

Expand All @@ -311,7 +311,7 @@ describe('Binding attribute syntax', {
ko.applyBindings(null, testNode);
value_of(testNode).should_contain_text("Hello WasBound Goodbye");
},

'Should be able to set and access correct context in custom containerless binding': function() {
ko.bindingHandlers.bindChildrenWithCustomContext = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
Expand All @@ -321,13 +321,13 @@ describe('Binding attribute syntax', {
}
};
ko.virtualElements.allowedBindings['bindChildrenWithCustomContext'] = true;

testNode.innerHTML = "Hello <!-- ko bindChildrenWithCustomContext: true --><div>Some text</div><!-- /ko --> Goodbye"
ko.applyBindings(null, testNode);

value_of(ko.dataFor(testNode.childNodes[2]).myCustomData).should_be(123);
},

'Should be able to set and access correct context in nested containerless binding': function() {
delete ko.bindingHandlers.nonexistentHandler;
ko.bindingHandlers.bindChildrenWithCustomContext = {
Expand All @@ -344,7 +344,7 @@ describe('Binding attribute syntax', {
value_of(ko.dataFor(testNode.childNodes[1].childNodes[0]).myCustomData).should_be(123);
value_of(ko.dataFor(testNode.childNodes[1].childNodes[1]).myCustomData).should_be(123);
},

'Should be able to access custom context variables in child context': function() {
ko.bindingHandlers.bindChildrenWithCustomContext = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
Expand All @@ -363,7 +363,7 @@ describe('Binding attribute syntax', {
value_of(ko.contextFor(testNode.childNodes[1].childNodes[1]).$parent.myCustomData).should_be(123);
value_of(ko.contextFor(testNode.childNodes[1].childNodes[1]).$parentContext.customValue).should_be('xyz');
},

'Should not reinvoke init for notifications triggered during first evaluation': function () {
var observable = ko.observable('A');
var initCalls = 0;
Expand All @@ -372,7 +372,7 @@ describe('Binding attribute syntax', {
initCalls++;

var value = valueAccessor();

// Read the observable (to set up a dependency on it), and then also write to it (to trigger re-eval of bindings)
// This logic probably wouldn't be in init but might be indirectly invoked by init
value();
Expand Down
Loading

0 comments on commit cbfc4b9

Please sign in to comment.