nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions

Home Page:https://swiperjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InjectStyles and InjectStylesUrls as Attributes in Swiper Element

mdmontesinos opened this issue · comments

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-element-inject-style-attributes-h9c5sr

Bug description

According to the official documentation for Swiper element:

image

Therefore, InjectStyles and InjectStylesUrls should also be supported in kebab-case (inject-styles, inject-styles-urls) as attributes, even though it's recommended to use parameters for "complex" cases.

However, both of them are required to be array objects:

image

image

And attributes are treated as strings, resulting in failing to init the swiper for the case of inject-styles-urls with the error:

image

Or just ignoring the styles when using inject-styles.

Expected Behavior

When using these parameters as attributes, the string values should be parsed into arrays so they can be properly injected.

image

Similar to how attributes that expect a type Object support a json string:

https://swiperjs.com/blog/swiper-v10#json-in-attributes

Actual Behavior

No response

Swiper version

11.1.1

Platform/Target and Browser Versions

Windows 10, Chrome 124

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR

It is impossible and doesn't make any sense to support arrays in HTML attribute. Pass them as element properties