@@ -4,11 +4,12 @@ import sinon from 'sinon';
44import '../src/vaadin-context-menu.js' ;
55import '@vaadin/item/src/vaadin-item.js' ;
66import '@vaadin/list-box/src/vaadin-list-box.js' ;
7- import { html , PolymerElement } from '@polymer/polymer/polymer-element.js' ;
87
9- class XFoo extends PolymerElement {
10- static get template ( ) {
11- return html `
8+ class XFoo extends HTMLElement {
9+ constructor ( ) {
10+ super ( ) ;
11+ this . attachShadow ( { mode : 'open' } ) ;
12+ this . shadowRoot . innerHTML = `
1213 <div id="wrapper">
1314 <div id="content"></div>
1415 </div>
@@ -19,7 +20,7 @@ class XFoo extends PolymerElement {
1920customElements . define ( 'x-foo' , XFoo ) ;
2021
2122describe ( 'context' , ( ) => {
22- let menu , foo , target , another ;
23+ let menu , foo , fooContent , target , another ;
2324
2425 beforeEach ( async ( ) => {
2526 menu = fixtureSync ( `
@@ -40,6 +41,7 @@ describe('context', () => {
4041 } ;
4142 await nextRender ( ) ;
4243 foo = document . querySelector ( 'x-foo' ) ;
44+ fooContent = foo . shadowRoot . querySelector ( '#content' ) ;
4345 target = document . querySelector ( '#target' ) ;
4446 another = document . querySelector ( '#another' ) ;
4547 } ) ;
@@ -68,14 +70,14 @@ describe('context', () => {
6870 } ) ;
6971
7072 it ( 'should use local target when targeting inside shadow root' , ( ) => {
71- fire ( foo . $ . content , 'contextmenu' ) ;
73+ fire ( fooContent , 'contextmenu' ) ;
7274
7375 expect ( menu . _context . target ) . to . eql ( foo ) ;
7476 } ) ;
7577
7678 it ( 'should not penetrate shadow root to change context' , ( ) => {
7779 menu . selector = '#content' ;
78- fire ( foo . $ . content , 'contextmenu' ) ;
80+ fire ( fooContent , 'contextmenu' ) ;
7981
8082 expect ( menu . _context . target ) . to . be . undefined ;
8183 } ) ;
@@ -89,14 +91,14 @@ describe('context', () => {
8991
9092 it ( 'should not open if no context available' , ( ) => {
9193 menu . selector = 'foobar' ;
92- fire ( foo . $ . content , 'contextmenu' ) ;
94+ fire ( fooContent , 'contextmenu' ) ;
9395
9496 expect ( menu . opened ) . to . eql ( false ) ;
9597 } ) ;
9698
9799 it ( 'should not prevent default if no context available' , ( ) => {
98100 menu . selector = 'foobar' ;
99- const evt = fire ( foo . $ . content , 'contextmenu' ) ;
101+ const evt = fire ( fooContent , 'contextmenu' ) ;
100102
101103 expect ( evt . defaultPrevented ) . to . eql ( false ) ;
102104 } ) ;
0 commit comments