Skip to content

Commit

Permalink
FIO-8302 Fixed issue with wizard api key overriding window.property o…
Browse files Browse the repository at this point in the history
…bjects (#5588)

* requireLibrary verifies that plugin is not of type HTMLElement

* requireLibrary verifies that plugin is not of type HTMLElement

* Added utility function for wizard ace issue
  • Loading branch information
ZenMasterJacob20011 authored May 27, 2024
1 parent c21885d commit fd05635
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/_classes/component/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit fd05635

Please sign in to comment.