You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you requesting a feature, reporting a bug or asking a question?
Bug
What is the current behavior?
We discovered this with custom properties, but reproduced it with built in properties.
Doing something like this: Survey.surveyLocalization.locales.en.startSurveyText = "{n}";
Will break the survey model constructor.
What is the expected behavior?
This is a regression.
How would you reproduce the current behavior (if this is a bug)?
surveyjs platform (angular or react or jquery or knockout or vue): knockout
surveyjs version: 107
Important
While the given example can be fixed by moving up the initialization of this.textPreProcessor in the Survey constructor, this will not fix the issue for custom properties.
Custom properties are added in the super() call by a parent class.
The issue is caused by a circular reference in base.ts:
This localizable string is passed the survey class as an implementor of ILocalizableOwner. But at this moment it cannot yet fully satisfy this interface since it has not been fully initialized...
The design flaw becomes obvious when you look at the typecasting needed to silence typescript.
I'm not sure what the best solution to untangle this is...
One possible solution that might work, without fixing the design, is to simply initialize the field in the declaration, not in the constructor:
Please reopen this, in v1.9.113 it's back in a different form.
publicgetVariable(name: string): any {if(!name)returnnull;name=name.toLowerCase();varres=this.variablesHash[name];if(!this.isValueEmpty(res))returnres;if(name.indexOf(".")>-1||name.indexOf("[")>-1){if(newProcessValue().hasValue(name,this.variablesHash))returnnewProcessValue().getValue(name,this.variablesHash);}returnres;}
Specifically this.variablesHash is access before being initialized.
It's trying to resolve the variable but failing to do so because the survey object is not fully initialized.
I think it's easier / more logical to handle translations after all initialization has been done.
Edit: I think this may never have actually been fixed, there were just more errors below the first one. In 106 it's broken.
Are you requesting a feature, reporting a bug or asking a question?
Bug
What is the current behavior?
We discovered this with custom properties, but reproduced it with built in properties.
Doing something like this:
Survey.surveyLocalization.locales.en.startSurveyText = "{n}";
Will break the survey model constructor.
What is the expected behavior?
This is a regression.
How would you reproduce the current behavior (if this is a bug)?
Provide the test code and the tested page URL (if applicable)
Check the developer console to see the error!
Tested page URL: https://plnkr.co/edit/7srGU5BPMpf66E90
Specify your
Important
While the given example can be fixed by moving up the initialization of
this.textPreProcessor
in theSurvey
constructor, this will not fix the issue for custom properties.Custom properties are added in the
super()
call by a parent class.The issue is caused by a circular reference in
base.ts
:This localizable string is passed the survey class as an implementor of
ILocalizableOwner
. But at this moment it cannot yet fully satisfy this interface since it has not been fully initialized...The design flaw becomes obvious when you look at the typecasting needed to silence typescript.
I'm not sure what the best solution to untangle this is...
One possible solution that might work, without fixing the design, is to simply initialize the field in the declaration, not in the constructor:
The text was updated successfully, but these errors were encountered: