Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addEventListeners(controller, options) {
options.onAcceptHandler = (e) => {
e.stopPropagation();
$mdcDialog.hide(controller ? controller.result : undefined);
};
options.onCancelHandler = (e) => {
e.stopPropagation();
$mdcDialog.cancel();
};
options.mdcDialog.listen(MDCDialogFoundation.strings.ACCEPT_EVENT, options.onAcceptHandler);
options.mdcDialog.listen(MDCDialogFoundation.strings.CANCEL_EVENT, options.onCancelHandler);
}
getActionFromEvent: (evt: React.SyntheticEvent & Event) => {
const element = closest(
evt.target,
`[${MDCDialogFoundation.strings.ACTION_ATTRIBUTE}]`
);
return (
element &&
element.getAttribute(MDCDialogFoundation.strings.ACTION_ATTRIBUTE)
);
},
clickDefaultButton: () => {
getActionFromEvent: (evt: React.SyntheticEvent & Event) => {
const element = closest(
evt.target,
`[${MDCDialogFoundation.strings.ACTION_ATTRIBUTE}]`
);
return (
element &&
element.getAttribute(MDCDialogFoundation.strings.ACTION_ATTRIBUTE)
);
},
clickDefaultButton: () => {
componentDidMount() {
super.componentDidMount();
this.container =
this.root.ref &&
this.root.ref.querySelector(
MDCDialogFoundation.strings.CONTAINER_SELECTOR
);
this.content =
this.root.ref &&
this.root.ref.querySelector(MDCDialogFoundation.strings.CONTENT_SELECTOR);
this.buttons =
this.root.ref &&
[].slice.call(
this.root.ref.querySelectorAll(
MDCDialogFoundation.strings.BUTTON_SELECTOR
)
);
this.defaultButton =
this.root.ref &&
this.root.ref.querySelector(
`[${MDCDialogFoundation.strings.BUTTON_DEFAULT_ATTRIBUTE}]`
function addEventListeners(controller, options) {
options.onAcceptHandler = (e) => {
e.stopPropagation();
$mdcDialog.hide(controller ? controller.result : undefined);
};
options.onCancelHandler = (e) => {
e.stopPropagation();
$mdcDialog.cancel();
};
options.mdcDialog.listen(MDCDialogFoundation.strings.ACCEPT_EVENT, options.onAcceptHandler);
options.mdcDialog.listen(MDCDialogFoundation.strings.CANCEL_EVENT, options.onCancelHandler);
}
);
this.content =
this.root.ref &&
this.root.ref.querySelector(MDCDialogFoundation.strings.CONTENT_SELECTOR);
this.buttons =
this.root.ref &&
[].slice.call(
this.root.ref.querySelectorAll(
MDCDialogFoundation.strings.BUTTON_SELECTOR
)
);
this.defaultButton =
this.root.ref &&
this.root.ref.querySelector(
`[${MDCDialogFoundation.strings.BUTTON_DEFAULT_ATTRIBUTE}]`
);
this.container &&
(this.focusTrap = createFocusTrap(this.container, {
initialFocus: undefined,
escapeDeactivates: false,
clickOutsideDeactivates: true
}));
this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(
this.foundation
);
document.addEventListener('keydown', this.handleDocumentKeydown);
}