diff --git a/docs/template/edx/publish.js b/docs/template/edx/publish.js index 4c390f56c..3c684cfbf 100644 --- a/docs/template/edx/publish.js +++ b/docs/template/edx/publish.js @@ -629,7 +629,7 @@ exports.publish = (memberData, opts, tutorials) => { generateSourceFiles(sourceFiles, opts.encoding); } - // if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } + if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } // index page displays information from package.json and lists files files = find({kind: 'file'}); diff --git a/src/react/hooks.js b/src/react/hooks.js index 77cc51a03..06d50e332 100644 --- a/src/react/hooks.js +++ b/src/react/hooks.js @@ -67,8 +67,8 @@ export const useTrackColorSchemeChoice = () => { /** * @typedef {object} ComponentPropOverridesOptions - * @property {string[]} [allowedPropNames] - The list of prop names allowed to be overridden. - * @property {boolean} [allowsDataAttributes] - Whether to allow `data-*` attributes to be applied. + * @property {string[]} [allowedPropNames=["className"]] - The list of prop names allowed to be overridden. + * @property {boolean} [allowsDataAttributes=true] - Whether to allow `data-*` attributes to be applied. */ /** @@ -114,20 +114,20 @@ export function useComponentPropOverrides(target, props, options = {}) { if (!target || !propOverridesForTarget) { return props; } - - const { + const overrideOptions = { // Allow for custom prop overrides to be applied to the component. These are // separate from any `data-*` attributes, which are always supported. - allowedPropNames = ['className'], + allowedPropNames: ['className'], // Allow for any `data-*` attributes to be applied to the component. - allowsDataAttributes = true, - } = options; + allowsDataAttributes: true, + ...options, + }; const updatedProps = { ...props }; // Apply the configured attributes/values/classes for the matched target Object.entries(propOverridesForTarget).forEach(([attributeName, attributeValue]) => { - const isAllowedPropName = allowedPropNames.includes(attributeName); - const isDataAttribute = allowsDataAttributes && attributeName.startsWith('data-'); + const isAllowedPropName = !!overrideOptions.allowedPropNames?.includes(attributeName); + const isDataAttribute = !!overrideOptions.allowsDataAttributes && attributeName.startsWith('data-'); const isAllowedPropOverride = isAllowedPropName || isDataAttribute; if (!isAllowedPropOverride) { // Skip applying the override prop if it's not allowed. diff --git a/src/react/withComponentPropOverrides.jsx b/src/react/withComponentPropOverrides.jsx index a20a49087..ee9552e7d 100644 --- a/src/react/withComponentPropOverrides.jsx +++ b/src/react/withComponentPropOverrides.jsx @@ -7,7 +7,7 @@ import { useComponentPropOverrides } from './hooks'; * actual component props. * * @param {string} [target] - The target used to identify any custom props for a given element. - * @param {import('./hooks').ComponentPropOverridesOptions} [options] - Optional configuration for the HOC. + * @param {ComponentPropOverridesOptions} [options] - Optional configuration for the HOC. * * @example * // Given a configuration like: