Skip to content

Commit e6023be

Browse files
committed
fixed data building
1 parent cd0df87 commit e6023be

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

dist/breinify-assets.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,16 @@
222222
});
223223
},
224224

225-
isMappedResource: function($el) {
226-
const data = $el.data(this.marker.mappedResourceData.settings);
225+
isMappedResource: function($el, data) {
226+
data = typeof data !== 'undefined' ? data : $el.data(this.marker.mappedResourceData.settings);
227227
return $.isPlainObject(data) && typeof data.mapId === 'string' && data.mapId !== '';
228228
},
229229

230230
refreshMappedResource: function ($el, settings) {
231231
const data = $el.data(this.marker.mappedResourceData.settings);
232-
233-
// mapId was no string and empty
234-
if (!$.isPlainObject(data) || typeof data.mapId !== 'string' || data.mapId === '') {
235-
return;
232+
if (this.isMappedResource($el, data)) {
233+
this._renderMappedResource($el, data.type, data.mapId, settings);
236234
}
237-
238-
this._renderMappedResource($el, data.type, data.mapId, settings);
239235
},
240236

241237
_handleMappedResource: function ($el, callback) {
@@ -252,8 +248,7 @@
252248
// determine the type (if we do not have one)
253249
let type = $el.attr('data-type');
254250
if (typeof type !== 'string' || type.trim() === '') {
255-
callback(new Error('missing type'));
256-
return;
251+
type = this.marker.mappedResourceAutoDetectionType;
257252
}
258253

259254
const render = function ($selectedEl, selectedType, foundMapId, cb) {
@@ -262,7 +257,10 @@
262257
if (typeof selectedType !== 'string' || selectedType.trim() === '') {
263258
cb(new Error('invalid type: ' + selectedType));
264259
} else {
265-
_self._renderMappedResource($selectedEl, selectedType, foundMapId, null, cb);
260+
const data = $selectedEl.data(_self.marker.mappedResourceData.settings);
261+
const currentSettings = $.isPlainObject(data.settings) ? data.settings : {};
262+
263+
_self._renderMappedResource($selectedEl, selectedType, foundMapId, currentSettings, cb);
266264
}
267265
};
268266

@@ -528,7 +526,7 @@
528526
}
529527

530528
const data = $resource.data(this.marker.mappedResourceData.settings);
531-
if (!$.isPlainObject(data) || typeof data.mapId !== 'string') {
529+
if (!this.isMappedResource($resource, data)) {
532530
return false;
533531
}
534532

0 commit comments

Comments
 (0)