Choices
Choices copied to clipboard
Adding ShadowDom support.
Description
This change allows for this library to work within a Shadow Dom If you have this library embedded within a shadow dom, it will not work Fixes:
- https://github.com/jshjohnson/Choices/issues/819
- https://github.com/jshjohnson/Choices/issues/805
Screenshots (if appropriate)
Types of changes
This adds a new configuration where you can pass the shadowRoot as a configuration. If you this configuration, then this will work in a shadow dom like so.
var shadowRoot = document.getElementById('wrapper').attachShadow({ mode: 'open' });
var choices = new Choices({
shadowRoot: shadowRoot
});
- [ ] Chore (tooling change or documentation change)
- [ ] Refactor (non-breaking change which maintains existing functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
What's the status of this PR @travist?
Is there a chance that this request will be merged or what still needs to be done?
I'm running into a similar issue. Trying to isolate the styles for the component using formio selector using Shadow Dom. Choices.js does not seem to work. @travist Do you have any idea if this PR will be merged in the near future?
Hello, @travist. I saw that the current version of Formio has modifications to the choice js within it; how do I make this work with Angular shadow DOM? I'm stuck since I don't know how to make it work with Angular using the code you gave in the readme file.
var shadowRoot = document.getElementById('wrapper').attachShadow({ mode: 'open' });
var choices = new Choices({
shadowRoot: shadowRoot
});
Thanks in advance.
My workaround can be helpful for someone: #805
is there any update on this?