Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update behavior method names #2100

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions packages/cfpb-design-system/src/utilities/behavior/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function _findElements(behaviorSelector, baseElement) {
behaviorElements.length === 0 &&
behaviorSelector.indexOf(BEHAVIOR_PREFIX) === -1
) {
behaviorElements = find(behaviorSelector, baseElement);
behaviorElements = behaviorFind(behaviorSelector, baseElement);
}

return behaviorElements;
Expand All @@ -60,7 +60,7 @@ function _findElements(behaviorSelector, baseElement) {
* for the behavior element.
* @returns {Array|NodeList} if it exists in the dom, null otherwise.
*/
function attach(behaviorElement, event, eventHandler, baseElement) {
function behaviorAttach(behaviorElement, event, eventHandler, baseElement) {
let behaviorElements = [];

if (behaviorElement instanceof NodeList === true) {
Expand Down Expand Up @@ -118,21 +118,12 @@ function checkBehaviorDom(element, behaviorDataAttr) {
* for the behavior element.
* @returns {NodeList} if it exists in the dom, null otherwise.
*/
function find(behaviorSelector, baseElement) {
function behaviorFind(behaviorSelector, baseElement) {
behaviorSelector = JS_HOOK + '*=' + BEHAVIOR_PREFIX + behaviorSelector;
behaviorSelector = '[' + behaviorSelector + ']';

return _findElements(behaviorSelector, baseElement);
}

/**
* @param {HTMLElement} behaviorElement - Element in which to remove the event.
* @param {string} event - Event type to remove from the element.
* @param {Function} eventHandler - Callback for event.
*/
function remove(behaviorElement, event, eventHandler) {
behaviorElement.removeEventListener(event, eventHandler);
}

// Expose public methods.
export { attach, checkBehaviorDom, find, remove };
export { behaviorAttach, checkBehaviorDom, behaviorFind };
6 changes: 5 additions & 1 deletion packages/cfpb-design-system/src/utilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export { EventObserver } from './event-observer.js';

export { checkDom, instantiateAll, setInitFlag } from './atomic-helpers.js';

export { attach, checkBehaviorDom, find, remove } from './behavior/behavior.js';
export {
behaviorAttach,
checkBehaviorDom,
behaviorFind,
} from './behavior/behavior.js';

export {
isUndefined,
Expand Down