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

fix: made defineProperty configurable as it broke when minified. #6586

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

PedroPovedaQ
Copy link
Contributor

@PedroPovedaQ PedroPovedaQ commented Apr 14, 2023

To reproduce the bug: Embed into a website.

Fixes the below issue where the build crashes when minified:

image

Minified Code Below:
paramsList.forEach((paramName) => {
  if (paramName === 'init') return;
  paramName = paramName.replace('_', '');
  Object.defineProperty(SwiperContainer.prototype, paramName, {
    / / added configurable:true  HERE to fix crash
    get() {
      return (this.passedParams || {})[paramName];
    },
    set(value) {
      if (!this.passedParams) this.passedParams = {};
      this.passedParams[paramName] = value;
      if (!this.initialized) return;
      this.updateSwiperOnPropChange(paramName, value);
    },
  });
});

It seems that the property is redefined in a later loop but as it is read only it crashes. Making it configurable fixes this issue.

@nolimits4web
Copy link
Owner

There shouldn't be such issue in today's release, or is it still there?

@PedroPovedaQ
Copy link
Contributor Author

There shouldn't be such issue in today's release, or is it still there?

I was using the following cdn include in my html:

<script src="https://cdn.jsdelivr.net/npm/swiper@9/swiper-element-bundle.min.js"></script>

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