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(svg parser): Ensure that applyViewboxTransform returns an object and not undefined/null #7030

Merged
merged 4 commits into from
Jun 13, 2021

Conversation

rockerBOO
Copy link
Contributor

@rockerBOO rockerBOO commented Apr 21, 2021

In fabric.parseSVGDocument, the options object was being set as undefined/null and causing options.crossOrigin to be invalid.

    TypeError: Cannot set property 'crossOrigin' of undefined

      19 | ): Promise<EcogardenFabricObject> =>
      20 |  new Promise((resolve) => {
    > 21 |      fabric.loadSVGFromString(
         |             ^
      at Object.<anonymous>.fabric.parseSVGDocument (node_modules/fabric/dist/fabric.js:4614:25)
      at Object.loadSVGFromString (node_modules/fabric/dist/fabric.js:4992:14)
      at src/js/lib/fabric.ts:21:10
    var svgUid =  fabric.Object.__uid++, i, len,
        options = applyViewboxTransform(doc),
        descendants = fabric.util.toArray(doc.getElementsByTagName('*'));
    options.crossOrigin = parsingOptions && parsingOptions.crossOrigin;

This pull request resolves applyViewboxTransform to always return an object.

Using fabricjs 4.4.0 and this was not erroring previously in 3.6.

@stale
Copy link

stale bot commented May 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue marked as stale by the stale bot label May 9, 2021
@asturur
Copy link
Member

asturur commented May 16, 2021

@rockerBOO can you remove the build dist file with the master one? so i can merge.
(i usually do git checkout master dist before committing)

@rockerBOO
Copy link
Contributor Author

Reverted dist/fabric.js to master. Thank you!

@stale stale bot closed this May 31, 2021
@asturur asturur removed the stale Issue marked as stale by the stale bot label Jun 13, 2021
@asturur asturur reopened this Jun 13, 2021
@asturur asturur changed the title fix: Ensure object returned from applyViewboxTransform fix(svg parser): Ensure that applyViewboxTransform returns an object and not undefined/null Jun 13, 2021
@asturur asturur merged commit b4f9310 into fabricjs:master Jun 13, 2021
@asturur asturur mentioned this pull request Jun 20, 2021
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