diff --git a/src/components/_classes/component/Component.js b/src/components/_classes/component/Component.js index 9daa721c25..6f56ccf326 100644 --- a/src/components/_classes/component/Component.js +++ b/src/components/_classes/component/Component.js @@ -8,7 +8,7 @@ import { processOne, processOneSync, validateProcessInfo } from '@formio/core/pr import { Formio } from '../../../Formio'; import * as FormioUtils from '../../../utils/utils'; import { - fastCloneDeep, boolValue, getComponentPath, isInsideScopingComponent, currentTimezone + fastCloneDeep, boolValue, getComponentPath, isInsideScopingComponent, currentTimezone, getScriptPlugin } from '../../../utils/utils'; import Element from '../../../Element'; import ComponentModal from '../componentModal/ComponentModal'; @@ -3750,7 +3750,7 @@ Component.requireLibrary = function(name, property, src, polling) { }.bind(Component.externalLibraries[name]); } // See if the plugin already exists. - const plugin = _.get(window, property); + const plugin = getScriptPlugin(property); if (plugin) { Component.externalLibraries[name].resolve(plugin); } @@ -3795,7 +3795,7 @@ Component.requireLibrary = function(name, property, src, polling) { // if no callback is provided, then check periodically for the script. if (polling) { setTimeout(function checkLibrary() { - const plugin = _.get(window, property); + const plugin = getScriptPlugin(property); if (plugin) { Component.externalLibraries[name].resolve(plugin); } diff --git a/src/utils/utils.js b/src/utils/utils.js index c06750eb3f..b0d2765552 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -150,6 +150,22 @@ export function getElementRect(element) { }; } +/** + * Get non HTMLElement property in the window object + * @param {String} property + * @return {any || undefined} + */ +export function getScriptPlugin(property) { + const obj = window[property]; + if ( + typeof HTMLElement === 'object' ? obj instanceof HTMLElement : //DOM2 + obj && typeof obj === 'object' && true && obj.nodeType === 1 && typeof obj.nodeName === 'string' + ) { + return undefined; + } + return obj; +} + /** * Determines the boolean value of a setting. *