Skip to content

NTR: frontend cleanup - JS files - #1419

Merged
BlackScorp merged 1 commit into
mollie:masterfrom
cxo-jutz:users/ju/ntr/js-plugin-clean-up
Jul 24, 2026
Merged

NTR: frontend cleanup - JS files#1419
BlackScorp merged 1 commit into
mollie:masterfrom
cxo-jutz:users/ju/ntr/js-plugin-clean-up

Conversation

@cxo-jutz

Copy link
Copy Markdown
Contributor

Small, behavior-preserving cleanups of the storefront JavaScript. No change to the
custom plugin base or the runtime-decoupling strategy.

Changes

  • http-client: fixed a broken error callback. xhr.onerror checked
    callbackSuccess instead of callbackError, so the error handler never fired.
    Also guarded onload against a missing content-type header (getResponseHeader
    returns null, and .indexOf() on it would throw).

  • Plugin base: added listener lifecycle. Introduced _addListener() (tracks each
    registered listener) and destroy() (removes them all). phone-plugin and
    subscribe-button now register through it. Shopware may re-initialize plugins on
    DOM updates (off-canvas cart, bfcache restore); without teardown this leaves
    duplicate listeners and leaks. Behavior is unchanged — the capture flag is passed
    through to both add/removeEventListener.

  • js- hook decoupling. Split styling classes from JS/test hooks (matches the
    project's existing stylelint rule that bans .js- classes from styling):

    • .mollie-paypal-button (styled) → JS now selects .js-mollie-paypal-button;
      the styling class stays on the element.
    • JS-only state marker observedjs-mollie-observed.
  • Removed dead IE / legacy-Edge detection. Dropped isIEBrowser, isEdgeBrowser,
    isNativeWindowsBrowser and getList from the device-detection helper, plus the
    IE-only TOS-checkbox workaround in the credit-card components (and its now-unused
    import).
    Why: IE is end-of-life, and isEdgeBrowser() matched the Edge/ UA token, which
    is legacy (EdgeHTML) Edge only — also discontinued. Modern Edge is Chromium and
    sends Edg/, so it was never matched by this code and needs none of these
    workarounds. No coverage lost for current browsers.

Notes / non-changes

  • Kept native querySelector/getElementById instead of Shopware's DomAccess:
    the storefront intentionally touches Shopware only via runtime globals
    (window.PluginManager, window.csrf) and avoids build-time imports from the
    Shopware source tree, to stay decoupled across SW 6.4–6.7.

@cxo-jutz
cxo-jutz force-pushed the users/ju/ntr/js-plugin-clean-up branch from 0d95d16 to 45a866c Compare July 24, 2026 12:27
@BlackScorp
BlackScorp merged commit 720b872 into mollie:master Jul 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants