Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Aug 19, 2024
1 parent ae7f974 commit 50344a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/template/edx/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
18 changes: 9 additions & 9 deletions src/react/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

/**
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/react/withComponentPropOverrides.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 50344a8

Please sign in to comment.