allow reference strip to work in a web component

This commit is contained in:
David McAlpine 2019-07-15 22:27:03 -04:00
parent ae3b049bb5
commit daa387f4b7
2 changed files with 27 additions and 1 deletions

View File

@ -236,7 +236,7 @@ $.extend( $.ReferenceStrip.prototype, $.EventSource.prototype, $.Viewer.prototyp
* @function
*/
setFocus: function ( page ) {
var element = $.getElement( this.element.id + '-' + page ),
var element = this.element.querySelector('#' + this.element.id + '-' + page ),
viewerSize = $.getElementSize( this.viewer.canvas ),
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ),

View File

@ -44,4 +44,30 @@
done();
});
// ----------
QUnit.test('shadow dom', function(assert) {
var done = assert.async();
var shadowDiv = document.createElement('div');
shadowDiv.attachShadow({
mode: 'open'
});
shadowDiv.shadowRoot.innerHTML = `<div id="shadow-example"></div>`
createViewer({
element: shadowDiv.shadowRoot.querySelector('#shadow-example'),
sequenceMode: true,
showReferenceStrip: true,
tileSources: [
'/test/data/tall.dzi',
'/test/data/wide.dzi'
]
});
$(shadowDiv).appendTo("#qunit-fixture");
assert.ok(viewer.referenceStrip, 'referenceStrip exists');
done();
})
})();