Skip to content

Missing changes (crossorigin) in 2.0.1 version #1273

@jenjen75

Description

@jenjen75

Cropper version

2.0.1

Link to minimal reproduction

https://unpkg.com/[email protected]/dist/cropper.js

Steps to reproduce

attribute crossorigin is not applied in 2.0.1 version.
#1253 fix the issue, but on npm, 2.0.1 doesn't have this fix.

https://unpkg.com/[email protected]/dist/cropper.js

if (template && isString(template)) {
          const templateElement = document.createElement('template');
          const documentFragment = document.createDocumentFragment();
          templateElement.innerHTML = template.replace(REGEXP_BLOCKED_TAGS, '<$1>');
          documentFragment.appendChild(templateElement.content);
          Array.from(documentFragment.querySelectorAll(CROPPER_IMAGE)).forEach((image) => {
              image.setAttribute('src', src);
              image.setAttribute('alt', element.alt || 'The image to crop');
          });
          if (element.parentElement) {
              element.style.display = 'none';
              container.insertBefore(documentFragment, element.nextSibling);
          }
          else {
              container.appendChild(documentFragment);
          }
      }

What is expected?

 Array.from(documentFragment.querySelectorAll(CROPPER_IMAGE)).forEach((image) => {
      image.setAttribute('src', src);
      image.setAttribute('alt', (element as HTMLImageElement).alt || 'The image to crop');
      if (element instanceof HTMLImageElement && typeof element.crossOrigin === 'string') {
        image.setAttribute('crossorigin', element.crossOrigin);
      }
    });

What is actually happening?

 Array.from(documentFragment.querySelectorAll(CROPPER_IMAGE)).forEach((image) => {
      image.setAttribute('src', src);
      image.setAttribute('alt', element.alt || 'The image to crop');
  });

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions