replaces direct call to document with abstraction

This commit is contained in:
Francisco Dans 2015-02-02 18:20:11 +01:00
parent d7ebab04d5
commit 3f33dc3428

View File

@ -135,10 +135,10 @@ var filters = require('./torque_filters');
ctx.translate(w/2, w/2);
function qualifyURL(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
};
var a = self._getDocument().createElement('a');
a.href = url;
return a.href;
};
var img_name = qualifyURL(st["marker-file"] || st["point-file"]);
if (img_name && this._icons.itemsToLoad === 0) {
var img = this._icons[img_name];
@ -198,6 +198,12 @@ var filters = require('./torque_filters');
: new Image();
},
_getDocument: function() {
return typeof this.options.document !== 'undefined'
? this.options.document
: document;
},
//
// renders a tile in the canvas for key defined in
// the torque tile
@ -315,7 +321,7 @@ var filters = require('./torque_filters');
for (var i = 0; i<img_names.length; i++){
var new_img = this._createImage();
function qualifyURL(url) {
var a = document.createElement('a');
var a = self._getDocument().createElement('a');
a.href = url;
return a.href;
}