[DEV-7060] Set document in constructor of ElementStyler
parent
e9ded067b1
commit
1e76291ada
|
@ -88,6 +88,12 @@ module.exports = Class( 'ElementStyler',
|
||||||
*/
|
*/
|
||||||
'private _jquery': null,
|
'private _jquery': null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML Document
|
||||||
|
* @type {HTMLElement}
|
||||||
|
*/
|
||||||
|
'private _document': null,
|
||||||
|
|
||||||
|
|
||||||
_answerStyles: {
|
_answerStyles: {
|
||||||
'deductible': function( value, _, default_val )
|
'deductible': function( value, _, default_val )
|
||||||
|
@ -193,6 +199,7 @@ module.exports = Class( 'ElementStyler',
|
||||||
{
|
{
|
||||||
this._$context = jquery;
|
this._$context = jquery;
|
||||||
this._jquery = jquery;
|
this._jquery = jquery;
|
||||||
|
this._document = jquery( 'body' ).context;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -858,7 +865,7 @@ module.exports = Class( 'ElementStyler',
|
||||||
|
|
||||||
if ( id )
|
if ( id )
|
||||||
{
|
{
|
||||||
element = document.getElementById( id );
|
element = this._document.getElementById( id );
|
||||||
|
|
||||||
// let's hope for the best
|
// let's hope for the best
|
||||||
if ( element !== null )
|
if ( element !== null )
|
||||||
|
|
|
@ -115,10 +115,15 @@ describe( 'ui.ElementStyler', () =>
|
||||||
{
|
{
|
||||||
it( "determines the correct element id for " + name, () =>
|
it( "determines the correct element id for " + name, () =>
|
||||||
{
|
{
|
||||||
// Stub all objects
|
// Stub document and jQuery calls
|
||||||
$ = sinon.stub();
|
$ = sinon.stub();
|
||||||
jQuery = sinon.stub();
|
jQuery = sinon.stub();
|
||||||
document = sinon.stub();
|
|
||||||
|
const document = {
|
||||||
|
getElementById: sinon.stub()
|
||||||
|
};
|
||||||
|
|
||||||
|
jQuery.withArgs( 'body' ).returns( { context: document } );
|
||||||
|
|
||||||
const sut = Sut( jQuery );
|
const sut = Sut( jQuery );
|
||||||
|
|
||||||
|
@ -136,7 +141,6 @@ describe( 'ui.ElementStyler', () =>
|
||||||
html: html,
|
html: html,
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById = sinon.stub();
|
|
||||||
document.getElementById.returns( node );
|
document.getElementById.returns( node );
|
||||||
|
|
||||||
sut.getWidgetByName( name, index, null, context );
|
sut.getWidgetByName( name, index, null, context );
|
||||||
|
|
Loading…
Reference in New Issue