🎨 Minor code structure changes

This commit is contained in:
Philipp Stracker 2024-06-12 11:27:59 +02:00
parent aa9c02a786
commit cea292684b
No known key found for this signature in database
4 changed files with 8 additions and 8 deletions

View file

@ -51,7 +51,7 @@ class ApplePayPreviewButtonManager extends PreviewButtonManager {
* @param {string} wrapperId - CSS ID of the wrapper element. * @param {string} wrapperId - CSS ID of the wrapper element.
* @return {ApplePayPreviewButton} * @return {ApplePayPreviewButton}
*/ */
createButtonInst(wrapperId) { createButtonInstance(wrapperId) {
return new ApplePayPreviewButton({ return new ApplePayPreviewButton({
selector: wrapperId, selector: wrapperId,
apiConfig: this.apiConfig apiConfig: this.apiConfig

View file

@ -116,9 +116,9 @@ class PreviewButton {
const buttonWrapper = previewButtonConfig.button.wrapper.replace(/^#/, '') const buttonWrapper = previewButtonConfig.button.wrapper.replace(/^#/, '')
const ppcpWrapper = this.ppcpConfig.button.wrapper.replace(/^#/, '') const ppcpWrapper = this.ppcpConfig.button.wrapper.replace(/^#/, '')
if (buttonWrapper === ppcpWrapper) { if (buttonWrapper === ppcpWrapper) {
throw new Error(`[APM Preview Button] Infinite loop detected. Provide different selectors for the button/ppcp wrapper elements! Selector: "#${buttonWrapper}"`); throw new Error(`[APM Preview Button] Infinite loop detected. Provide different selectors for the button/ppcp wrapper elements! Selector: "#${buttonWrapper}"`);
} }
this.createButton(previewButtonConfig) this.createButton(previewButtonConfig)
} }

View file

@ -59,8 +59,8 @@ class PreviewButtonManager {
* @param {string} wrapperId - CSS ID of the wrapper element. * @param {string} wrapperId - CSS ID of the wrapper element.
* @return {PreviewButton} * @return {PreviewButton}
*/ */
createButtonInst(wrapperId) { createButtonInstance(wrapperId) {
throw new Error('The "createButtonInst" method must be implemented by the derived class'); throw new Error('The "createButtonInstance" method must be implemented by the derived class');
} }
registerEventListeners() { registerEventListeners() {
@ -183,7 +183,7 @@ class PreviewButtonManager {
#addButton(id, ppcpConfig) { #addButton(id, ppcpConfig) {
const createButton = () => { const createButton = () => {
if (!this.buttons[id]) { if (!this.buttons[id]) {
this.buttons[id] = this.createButtonInst(id).setButtonConfig(this.buttonConfig); this.buttons[id] = this.createButtonInstance(id).setButtonConfig(this.buttonConfig);
} }
this.#configureButton(id, ppcpConfig); this.#configureButton(id, ppcpConfig);

View file

@ -51,7 +51,7 @@ class GooglePayPreviewButtonManager extends PreviewButtonManager {
* @param {string} wrapperId - CSS ID of the wrapper element. * @param {string} wrapperId - CSS ID of the wrapper element.
* @return {GooglePayPreviewButton} * @return {GooglePayPreviewButton}
*/ */
createButtonInst(wrapperId) { createButtonInstance(wrapperId) {
return new GooglePayPreviewButton({ return new GooglePayPreviewButton({
selector: wrapperId, selector: wrapperId,
apiConfig: this.apiConfig apiConfig: this.apiConfig