-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Dialog validators does not work if there is no 'getValue()' method provided in the current context #4473
Comments
Related? #4449 |
@bunglegrind I was checking it, but it seems those are different issues. As you mentioned in #4449 (comment)
Should be enough to fix #4449. And here the fix would be replacing: var value = this && this.getValue ? this.getValue() : args[ 0 ]; with var value = this && this.getValue ? this.getValue() : arguments[ 0 ]; so that Still, it would be reasonable to fix both in one PR seems they concern the same function. |
Looks like |
- establish validators results based on doc samples
get rid of extra code caused by #4473
- establish validators results based on doc samples
get rid of extra code caused by #4473
Closed in #5254 |
Type of report
Bug
Provide detailed reproduction steps (if any)
The
dialog
plugin provides it's own set of validators, for examplecssLength
:ckeditor4/plugins/dialog/plugin.js
Lines 3341 to 3345 in 5380706
And the API docs states they can be simply used as follows:
However, such calls throws an error:
Expected result
It works as described in API docs.
Actual result
Error is thrown.
Other details
Well, that's the interesting part... Many of the validators use special
functions()
method which combines validators:ckeditor4/plugins/dialog/plugin.js
Lines 3219 to 3258 in 5380706
When the validator is created (like in
cssLength
above),functions()
returns another function (let's call itvalidatorFn()
) which has access to initialargs
. This means callingCKEDITOR.dialog.validate.cssLength( 'error!' )
internally calls:ckeditor4/plugins/dialog/plugin.js
Lines 3342 to 3344 in 5380706
Which returns
validatorFn()
mentioned above. This functions accesses the value to be validated in two ways. UsinggetValue()
method from the current context or accessingargs[ 0 ]
(the ones fromfunctions()
call):ckeditor4/plugins/dialog/plugin.js
Line 3226 in 5380706
If
getValue()
method is present in the current context everything works fine. But if not,args[ 0 ]
are used as a value to be validated. However, in the context of.functions( cssLengthInternalFn, 'error!' )
call,args[ 0 ]
arecssLengthInternalFn
(so the validator function). And soargs[ 0 ]
are both used as validator function and value to be validated (not a string soUncaught TypeError: b.replace is not a function
is thrown).I wonder if the API docs are just confusing and it was never meant to be used without extending dialog and adding
getValue()
there, but the comment there states it should work:ckeditor4/plugins/dialog/plugin.js
Lines 3222 to 3226 in 5380706
4.10.0
but looking at git history it might be4.0.0
as well 🤔dialog
The text was updated successfully, but these errors were encountered: