create-element-if-not-defined.js 656 B

1234567891011121314151617181920212223
  1. import { getDocument } from 'ssr-window';
  2. export default function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
  3. const document = getDocument();
  4. if (swiper.params.createElements) {
  5. Object.keys(checkProps).forEach(key => {
  6. if (!params[key] && params.auto === true) {
  7. let element = swiper.$el.children(`.${checkProps[key]}`)[0];
  8. if (!element) {
  9. element = document.createElement('div');
  10. element.className = checkProps[key];
  11. swiper.$el.append(element);
  12. }
  13. params[key] = element;
  14. originalParams[key] = element;
  15. }
  16. });
  17. }
  18. return params;
  19. }