-
Notifications
You must be signed in to change notification settings - Fork 8
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
closest() breaks use of bpmn-js inside shadow DOM #5
Comments
Could you add a PR that includes the implementation in min-dom itself? We'd need accompanying test cases, too, otherwise we cannot accept the contribution. |
Have patched code and written a test, but think maybe there is a less invasive solution. The min-dom depends on matches-selector ^1.2.0 whereas closest 0.0.1 depends on (and ends up using) matches-selector 0.0.1. Starting with version 0.0.2, matches-selector directly uses I noticed this since my test that threw the expected TypeError stopped doing that immediately as I copied the code over from closest 0.0.1. My DocumentFragment check was not required since the matches-selector ^1.2.0 of min-dom solved it for me.
Depending on something like https://www.npmjs.com/package/component-closest/v/0.1.4 (old enough to be compatible) instead of https://www.npmjs.com/package/closest/v/0.0.1 is an option I'll look into next. |
Going with Pull request #6 |
bpmn-io/min-dom#5 위와 관련된 이슈로 인해서, bpmn-js와 min-dom 리파지토리를 fork 해서 사용함.
The problem with this issue is that we don't have built in shadow related DOM functionalities such as attachShadow within PhantomJS context. For instance:
would print undefined. The original PR has a single test case which covers document fragments rather than shadow dom. So even though we support shadow dom, we won't be able to test this. I'll try to use different headless browsers. |
Update: Using "karma-chrome-launcher" instead of "karma-phantomjs-launcher" fixes the issue I mentioned above. |
The reason we use |
Makes sense. So I'll fix the issue, verify it without tests, will include document fragment tests just in case. |
Conditionally include document fragment tests: (IS_FRAGMENT_SUPPORTED ? it : it.skip)('execute document fragment related tests', function() {
...
}); |
Good news: The issue can be reproduced with the following test (using Chrome headless browser): it.only('should get closest parent inside shadow DOM', function() {
var rootDiv = document.createElement('div');
var childDiv = document.createElement('div');
var shadow = childDiv.attachShadow({mode: 'open'});
var para = document.createElement('p');
shadow.appendChild(para);
rootDiv.appendChild(childDiv);
rootDiv.className = 'root';
childDiv.className = 'child';
para.className = 'para';
console.log(closest(childDiv, '.root')); // prints rootDiv
console.log(closest(para, '.root')); // TypeError: Illegal invocation
}); |
I have same Issue with Function "match$1" while embedding bpmn-io in vaadin flow:
You fixed function with nearly the same name: Why do both exists? And why has just the first one the new if-statement with nodeType? Thank you |
Please open a new issue that clearly makes your case. Use the bug report template and provide all information necessary for us to help you out. |
The
closest()
implementation loops until parentNode is undefined ordocument
. For the general case this is fine, but when using shadow DOM we will stumble onto a document fragment on the way that is the shadow root. Performing thematches()
code on that fragment causesTypeError: Illegal Invocation
.Many of the forks of the
closest
repository have fixes for this. The current version 1.0.1 of thecomponent
fork seems to have a slightly different function prototype so if I were to submit a patch to them then there would still be work done for all code using min-dom. Maybe the best fix is to actually include an implementation in the min-dom itself rather than importing/exporting that ofcomponent
.This change I made directly in
node_modules
, giving me a working bpmn-js modeller (MoveCanvas was broken):This is another implementation I found in a fork later on:
The text was updated successfully, but these errors were encountered: