Title: No longer possible to run tests for components which import plotly without a browser · Issue #1675 · plotly/plotly.js · GitHub
Open Graph Title: No longer possible to run tests for components which import plotly without a browser · Issue #1675 · plotly/plotly.js
X Title: No longer possible to run tests for components which import plotly without a browser · Issue #1675 · plotly/plotly.js
Description: Recently a change was made to svg_text_utils.js which instantiates a DOMParser at the top level of that module: plotly.js/src/lib/svg_text_utils.js Line 22 in ce970f1 var parser = new DOMParser(); . This has broken a number of tests I ha...
Open Graph Description: Recently a change was made to svg_text_utils.js which instantiates a DOMParser at the top level of that module: plotly.js/src/lib/svg_text_utils.js Line 22 in ce970f1 var parser = new DOMParser(); ...
X Description: Recently a change was made to svg_text_utils.js which instantiates a DOMParser at the top level of that module: plotly.js/src/lib/svg_text_utils.js Line 22 in ce970f1 var parser = new DOMParser(); ...
Opengraph URL: https://github.com/plotly/plotly.js/issues/1675
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No longer possible to run tests for components which import plotly without a browser","articleBody":"Recently a change was made to _svg_text_utils.js_ which instantiates a DOMParser at the top level of that module: https://github.com/plotly/plotly.js/blob/ce970f112a8fff0d09909529be8a713f5d4f36cc/src/lib/svg_text_utils.js#L22.\r\n\r\nThis has broken a number of tests I have which do not use a browser (or jsdom etc..) because the DOMParser will be instantiated on import, giving the following:\r\n```\r\nvar parser = new DOMParser();\r\n ^\r\n\r\nReferenceError: DOMParser is not defined\r\n at Object.\u003canonymous\u003e (/home/user/repo/node_modules/plotly.js/src/lib/svg_text_utils.js:22:18)\r\n...\r\n```\r\nFor now I've applied a very quick fix:\r\n```\r\nvar parser;\r\nfunction cachingParser() {\r\n parser = parser === undefined ? new DOMParser(): parser;\r\n return parser\r\n};\r\n...\r\nvar dom = cachingParser().parseFromString(skeleton, 'application/xml'),\r\n childNode = dom.documentElement.firstChild;\r\n...\r\n```\r\nCan this be updated to something like the above? If not, then does the DOMParser really need to be at the top level?","author":{"url":"https://github.com/wayofthepie","@type":"Person","name":"wayofthepie"},"datePublished":"2017-05-11T21:45:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1675/plotly.js/issues/1675"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff220a61-cd5d-cd76-4d38-5c07dd74047b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 91B6:151D81:69698A:8B27F2:6A5BDC56 |
| html-safe-nonce | 6151c0329481ff9789d50d2456b897aed99a269b6f78551b8dcf1b6789c14528 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUI2OjE1MUQ4MTo2OTY5OEE6OEIyN0YyOjZBNUJEQzU2IiwidmlzaXRvcl9pZCI6IjUxNTU4NDA5OTkxNzczMTMzNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 38a91d476308cef5fd94215b62bedc9e5d6f4791e62c346454040596b562ca32 |
| hovercard-subject-tag | issue:228130234 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.js/1675/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7c0429cc2b220b44a629f647914491b12c8fd8bcf94acf0cc96e1b1402d727e9/plotly/plotly.js/issues/1675 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7c0429cc2b220b44a629f647914491b12c8fd8bcf94acf0cc96e1b1402d727e9/plotly/plotly.js/issues/1675 |
| og:image:alt | Recently a change was made to svg_text_utils.js which instantiates a DOMParser at the top level of that module: plotly.js/src/lib/svg_text_utils.js Line 22 in ce970f1 var parser = new DOMParser(); ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wayofthepie |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.js git https://github.com/plotly/plotly.js.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 45646037 |
| octolytics-dimension-repository_nwo | plotly/plotly.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 45646037 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.js |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width