Skip to content

Commit

Permalink
replace tab to space
Browse files Browse the repository at this point in the history
  • Loading branch information
haru01 committed Jun 25, 2014
1 parent 7ae7194 commit 91a1cd4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
30 changes: 15 additions & 15 deletions spec/jsonPostingBehaviors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('JSON posting', function() {
it('Should stringify and post the supplied data to a supplied URL', function () {
var submittedForm;
var submittedForm;
ko.utils.postJson('http://example.com/some/url', {myModel : {a : 1}}, { submitter : function(x) { submittedForm = x } });

expect(submittedForm.action).toEqual('http://example.com/some/url');
Expand All @@ -11,39 +11,39 @@ describe('JSON posting', function() {
});

it('Given an existing form, should take the URL from the form\'s \'action\' attribute', function() {
var existingForm = document.createElement("FORM");
existingForm.action = 'http://example.com/blah';
var existingForm = document.createElement("FORM");
existingForm.action = 'http://example.com/blah';

var submittedForm;
var submittedForm;
ko.utils.postJson(existingForm, {myModel : {a : 1}}, { submitter : function(x) { submittedForm = x } });

expect(submittedForm.action).toEqual('http://example.com/blah');
});

it('Given an existing form, should include any requested field values from that form', function() {
var existingForm = document.createElement("FORM");
existingForm.innerHTML = '<input name="someField" value="myValue"/><input name="anotherField" value="unwantedValue"/>';
var existingForm = document.createElement("FORM");
existingForm.innerHTML = '<input name="someField" value="myValue"/><input name="anotherField" value="unwantedValue"/>';

var submittedForm;
var submittedForm;
ko.utils.postJson(existingForm, {myModel : {a : 1}}, { includeFields : ['someField'], submitter : function(x) { submittedForm = x } });

expect(ko.utils.getFormFields(submittedForm, 'someField')[0].value).toEqual('myValue');
expect(ko.utils.getFormFields(submittedForm, 'anotherField').length).toEqual(0);
});
});

it('Given an existing form, should include Rails and ASP.NET MVC auth tokens by default', function() {
var existingForm = document.createElement("FORM");
existingForm.innerHTML = '<input name="__RequestVerificationToken_Lr4e" value="wantedval1"/>'
+ '<input name="__RequestVe" value="unwantedval"/>'
+ '<input name="authenticity_token" value="wantedval2"/>';
it('Given an existing form, should include Rails and ASP.NET MVC auth tokens by default', function() {
var existingForm = document.createElement("FORM");
existingForm.innerHTML = '<input name="__RequestVerificationToken_Lr4e" value="wantedval1"/>'
+ '<input name="__RequestVe" value="unwantedval"/>'
+ '<input name="authenticity_token" value="wantedval2"/>';

var submittedForm;
var submittedForm;
ko.utils.postJson(existingForm, {myModel : {a : 1}}, { submitter : function(x) { submittedForm = x } });

expect(ko.utils.getFormFields(submittedForm, '__RequestVerificationToken_Lr4e')[0].value).toEqual('wantedval1');
expect(ko.utils.getFormFields(submittedForm, '__RequestVe').length).toEqual(0);
expect(ko.utils.getFormFields(submittedForm, 'authenticity_token')[0].value).toEqual('wantedval2');
});
});

it('Should not truncate large values', function() {
// Represents https://github.com/knockout/knockout/issues/1252
Expand Down
8 changes: 4 additions & 4 deletions src/binding/defaultBindings/text.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ko.bindingHandlers['text'] = {
'init': function() {
// Prevent binding on the dynamically-injected text node (as developers are unlikely to expect that, and it has security implications).
// It should also make things faster, as we no longer have to consider whether the text node might be bindable.
'init': function() {
// Prevent binding on the dynamically-injected text node (as developers are unlikely to expect that, and it has security implications).
// It should also make things faster, as we no longer have to consider whether the text node might be bindable.
return { 'controlsDescendantBindings': true };
},
},
'update': function (element, valueAccessor) {
ko.utils.setTextContent(element, valueAccessor());
}
Expand Down
16 changes: 8 additions & 8 deletions src/google-closure-compiler-utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Google Closure Compiler helpers (used only to make the minified file smaller)
ko.exportSymbol = function(koPath, object) {
var tokens = koPath.split(".");
var tokens = koPath.split(".");

// In the future, "ko" may become distinct from "koExports" (so that non-exported objects are not reachable)
// At that point, "target" would be set to: (typeof koExports !== "undefined" ? koExports : ko)
var target = ko;
// In the future, "ko" may become distinct from "koExports" (so that non-exported objects are not reachable)
// At that point, "target" would be set to: (typeof koExports !== "undefined" ? koExports : ko)
var target = ko;

for (var i = 0; i < tokens.length - 1; i++)
target = target[tokens[i]];
target[tokens[tokens.length - 1]] = object;
for (var i = 0; i < tokens.length - 1; i++)
target = target[tokens[i]];
target[tokens[tokens.length - 1]] = object;
};
ko.exportProperty = function(owner, publicName, object) {
owner[publicName] = object;
owner[publicName] = object;
};

0 comments on commit 91a1cd4

Please sign in to comment.