Skip to content

Commit

Permalink
Revert "Proviede possibility to bind also arguments to function not o…
Browse files Browse the repository at this point in the history
…nly context with CKEDITOR.tools.bind"

Functionality separates to own PR #2862.

This reverts commit 7383b2d.
  • Loading branch information
Mateusz Samsel committed Feb 26, 2019
1 parent bf548d7 commit ca47c70
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 61 deletions.
4 changes: 1 addition & 3 deletions core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,12 @@
*
* @param {Function} func The function to be executed.
* @param {Object} obj The object to which the execution context will be bound.
* @param {*} [args] Other arguments passed after object, will be bind to executed function.
* @returns {Function} The function that can be used to execute the
* `func` function in the context of `obj`.
*/
bind: function( func, obj ) {
var args = Array.prototype.slice.call( arguments, 2 );
return function() {
return func.apply( obj, args.concat( Array.prototype.slice.call( arguments ) ) );
return func.apply( obj, arguments );
};
},

Expand Down
58 changes: 0 additions & 58 deletions tests/core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,64 +1024,6 @@
CKEDITOR.tools.array.forEach( conversionArray, function( item ) {
assert.areSame( item.output, CKEDITOR.tools.convertToPx( item.input ), 'Value ' + item.input + ' should be converted to ' + item.output );
} );
},

'test bind without context and without arguments': function() {
var testSpy = sinon.spy(),
bindedFn = CKEDITOR.tools.bind( testSpy );

bindedFn( 'foo' );
assert.areSame( 1, testSpy.callCount );
assert.isTrue( testSpy.calledWithExactly( 'foo' ) );

bindedFn( 'bar' );
assert.areSame( 2, testSpy.callCount );
assert.isTrue( testSpy.calledWithExactly( 'bar' ) );
},

'text bind with context and without arguments': function() {
var testSpy = sinon.spy(),
testObj = {},
bindedFn = CKEDITOR.tools.bind( testSpy, testObj );

bindedFn( 'foo' );
assert.areSame( 1, testSpy.callCount );
assert.areSame( testObj, testSpy.getCall( 0 ).thisValue );
assert.isTrue( testSpy.calledWithExactly( 'foo' ) );

bindedFn( 'bar' );
assert.areSame( 2, testSpy.callCount );
assert.areSame( testObj, testSpy.getCall( 1 ).thisValue );
assert.isTrue( testSpy.calledWithExactly( 'bar' ) );
},

'test bind without context and with arguments': function() {
var testSpy = sinon.spy(),
bindedFn = CKEDITOR.tools.bind( testSpy, null, 'baz', 100 );

bindedFn( 'foo' );
assert.areSame( 1, testSpy.callCount );
assert.isTrue( testSpy.calledWithExactly( 'baz', 100, 'foo' ) );

bindedFn( 'bar' );
assert.areSame( 2, testSpy.callCount );
assert.isTrue( testSpy.calledWithExactly( 'baz', 100, 'bar' ) );
},

'text bind with context and with arguments': function() {
var testSpy = sinon.spy(),
testObj = {},
bindedFn = CKEDITOR.tools.bind( testSpy, testObj, 'baz', 100 );

bindedFn( 'foo' );
assert.areSame( 1, testSpy.callCount );
assert.areSame( testObj, testSpy.getCall( 0 ).thisValue );
assert.isTrue( testSpy.calledWithExactly( 'baz', 100, 'foo' ) );

bindedFn( 'bar' );
assert.areSame( 2, testSpy.callCount );
assert.areSame( testObj, testSpy.getCall( 0 ).thisValue );
assert.isTrue( testSpy.calledWithExactly( 'baz', 100, 'bar' ) );
}
} );
} )();

0 comments on commit ca47c70

Please sign in to comment.