Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for: table dialog validator fails when function getValue is defined in global scope #2652

Merged
merged 4 commits into from Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -11,6 +11,7 @@ Fixed Issues:
* [#2451](https://github.com/ckeditor/ckeditor-dev/issues/2451): Fixed: The [Remove Format](https://ckeditor.com/cke4/addon/removeformat) changes selection.
* [#2546](https://github.com/ckeditor/ckeditor-dev/issues/2546): Fixed: Separator in toolbar moves when buttons are focused.
* [#2506](https://github.com/ckeditor/ckeditor-dev/issues/2506): Fixed: [Enhanced Image](https://ckeditor.com/cke4/addon/image2) throws type error when empty figure tag with 'image' class is upcasted.
* [#2650](https://github.com/ckeditor/ckeditor-dev/issues/2650): Fixed: [Table](https://ckeditor.com/cke4/addon/table) dialog validator fails when function `getValue` is defined in global scope.

Other Changes:

Expand Down
2 changes: 1 addition & 1 deletion plugins/table/dialogs/table.js
Expand Up @@ -34,7 +34,7 @@
function validatorNum( msg ) {
return function() {
var value = this.getValue(),
pass = !!( CKEDITOR.dialog.validate.integer()( value ) && value > 0 );
pass = !!( CKEDITOR.dialog.validate.integer().call( this, value ) && value > 0 );

if ( !pass ) {
alert( msg ); // jshint ignore:line
Expand Down
6 changes: 6 additions & 0 deletions tests/plugins/table/manual/dialogvalidate.html
@@ -0,0 +1,6 @@
<textarea id="editor"></textarea>

<script>
CKEDITOR.replace( 'editor' );
window.getValue = function() {return false;}
</script>
15 changes: 15 additions & 0 deletions tests/plugins/table/manual/dialogvalidate.md
@@ -0,0 +1,15 @@
@bender-tags: 4.11.2, bug, 2650
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea,toolbar,table,sourcearea,dialogadvtab

1. Open table dialog.
2. Press `ok`.

## Expected

Table is inserted into editor.

## Unexpected

Alert popups with information:
`Number of rows must be a number greater than 0.`
20 changes: 20 additions & 0 deletions tests/plugins/table/validate.js
@@ -0,0 +1,20 @@
/* bender-tags: editor */
/* bender-ckeditor-plugins: dialogadvtab,table,toolbar,wysiwygarea */

( function() {
'use strict';

bender.editor = {};

bender.test( {
// #2650
'test validator when global scope is polluted': function() {
this.editorBot.dialog( 'table', function( dialog ) {
var spy = window.getValue = sinon.spy();

dialog.getButton( 'ok' ).click();
assert.isFalse( spy.called );
} );
}
} );
} )();