-
Notifications
You must be signed in to change notification settings - Fork 610
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
Cannot use Choices if rendered from iframe #1057
Comments
The previous check using `instanceof` fails in case the Choices.js component is rendered in the `top` frame while the JavaScript actually using Choices.js is in an iframe. The conditions are changed to check for `constructor.name` now, solving the issue. Due to the rather messy constructor, some quirks like operational chaining and explict type casts needs to be used to make the TypeScript compiling process happy. Fixes: Choices-js#1057
The previous check using `instanceof` fails in case the Choices.js component is rendered in the `top` frame while the JavaScript actually using Choices.js is in an iframe. The conditions are changed to check for `constructor.name` now, solving the issue. Due to the rather messy constructor, some quirks like operational chaining and explicit type casts need to be used to make the TypeScript compiling process happy. Fixes: Choices-js#1057
The previous check using `instanceof` fails in case the Choices.js component is rendered in the `top` frame while the JavaScript actually using Choices.js is in an iframe. The conditions are changed to check for `constructor.name` now, solving the issue. Due to the rather messy constructor, some quirks like operational chaining and explicit type casts need to be used to make the TypeScript compiling process happy. Fixes: Choices-js#1057
+1. I have a similar problem. |
+1 for me as well, I found that the issue is probably because of the use of I think the best solution here would be to replace instanceOf check for something else like nodeName or anything else that is constant and persistent. |
Describe the bug
Disclaimer: To be honest, this is a kinda special setup.
I have a modal window whose content contains a
select
field that is used to initialize Choices.js. There are two scopes where this modal may be opened:iframe
, where the modal is rendered in the top frameIn the latter case, I get the error "Expected one of the following types text|select-one|select-multiple". The issue is that the
instanceof
check for the passed element to initialize Choices.js does not work in case of an inter-frame communication. In my tests it was safe to checkpassedElement.constructor.name
instead.Since the fix is rather easy I'll push a PR ASAP.
To Reproduce
Steps to reproduce the behavior:
select
element on the top frameExpected behavior
I expect that Choices.js works in the scenarios mentioned above.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: