Skip to content

Commit cf69461

Browse files
committed
Fix for createShadowRoot being removed.
1 parent 755dbf9 commit cf69461

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

positionable.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,9 @@ class ShadowDomInjector {
708708
}
709709
container.className = ShadowDomInjector.UI_HOST_CLASS_NAME;
710710

711-
// Note that changing this to attachShadow was causing some weird
712-
// issues with eventing (window copy event was not firing) in both
713-
// open and closed modes, so going back to createShadowRoot.
714-
var root = container.createShadowRoot();
711+
var root = container.attachShadow({
712+
mode: 'open'
713+
});
715714

716715
// Relative extension paths don't seem to be supported in HTML template
717716
// files, so manually swap out these tokens for the extension path.

test/helpers/events.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
}, opt);
1313
var evt = new MouseEvent(type, opt);
1414
el.dispatchEvent(evt);
15+
16+
// Simulate bubbling outside the shadow DOM.
17+
const hostElement = getHostElement(el);
18+
if (hostElement) {
19+
fireMouseEvent(type, hostElement, x, y, opt);
20+
}
1521
}
1622

1723
function fireMouseDown(el, x, y, opt) {
@@ -122,6 +128,7 @@
122128
// --- Private
123129

124130
function executeElementDrag(el, points) {
131+
125132
var x, y, opt;
126133
for (let i = 0, point; point = points[i]; i++) {
127134
checkDragKeysChanged(point[2], opt);
@@ -141,6 +148,13 @@
141148
fireMouseOut(el, x, y, opt);
142149
}
143150

151+
function getHostElement(el) {
152+
const root = el.getRootNode();
153+
if (root instanceof ShadowRoot) {
154+
return root.host;
155+
}
156+
}
157+
144158
function checkDragKeysChanged(opt, lastOpt) {
145159
lastOpt = lastOpt || {};
146160
checkKeyChangeAndFire(opt.altKey, lastOpt.altKey, 'Alt', opt);

test/tests/positionable-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ describe('PositionableElement', function() {
564564
setupBox('animation-box');
565565
element.pushState();
566566
element.resize(100, 100, 'se');
567-
assert.equal(el.style.animation, 'none');
567+
assert.equal(el.style.animation, '0s ease 0s 1 normal none running none');
568568
element.destroy();
569569
assert.equal(el.style.animation, '');
570570
});

0 commit comments

Comments
 (0)