Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Dompurify Hooks #5236

Merged
merged 2 commits into from
Jan 27, 2024
Merged

fix: Dompurify Hooks #5236

merged 2 commits into from
Jan 27, 2024

Conversation

sidharthv96
Copy link
Member

@sidharthv96 sidharthv96 commented Jan 25, 2024

📑 Summary

Only add DOMPurify hooks if necessary, and remove them after use.

This was causing huge slowdown in rendering.

Resolves issue introduced in #4933

📏 Design Decisions

These hooks are not necessary for most diagrams. Also, we keep adding them with every render, slowing mermaid down quite a bit.

Now we add it if required and remove them after the call.

📋 Tasks

Make sure you

Copy link

netlify bot commented Jan 25, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 7ca990d
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/65b40016816c3900085dd4c0
😎 Deploy Preview https://deploy-preview-5236--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Jan 25, 2024
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (91907fe) 43.04% compared to head (7ca990d) 79.99%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #5236       +/-   ##
============================================
+ Coverage    43.04%   79.99%   +36.95%     
============================================
  Files           23      167      +144     
  Lines         5018    13898     +8880     
  Branches        21      710      +689     
============================================
+ Hits          2160    11118     +8958     
+ Misses        2857     2627      -230     
- Partials         1      153      +152     
Flag Coverage Δ
e2e 85.94% <100.00%> (?)
unit 43.21% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/mermaid/src/diagrams/common/common.ts 70.06% <100.00%> (+17.47%) ⬆️

... and 162 files with indirect coverage changes

Currently, everytime `removeScript()` is called, the same DOMPurify
hooks are getting added again and again.

Co-authored-by: Alois Klink <alois@aloisklink.com>
@sidharthv96 sidharthv96 added this pull request to the merge queue Jan 27, 2024
Merged via the queue into develop with commit c5272d5 Jan 27, 2024
30 checks passed
@sidharthv96 sidharthv96 deleted the fix/DompurifyHooks branch January 27, 2024 15:34
fuxingloh referenced this pull request in fuxingloh/contented Feb 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [mermaid](https://github.com/mermaid-js/mermaid) | [`10.7.0` ->
`10.8.0`](https://renovatebot.com/diffs/npm/mermaid/10.7.0/10.8.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/mermaid/10.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/mermaid/10.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/mermaid/10.7.0/10.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/mermaid/10.7.0/10.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>mermaid-js/mermaid (mermaid)</summary>

###
[`v10.8.0`](https://github.com/mermaid-js/mermaid/releases/tag/v10.8.0)

[Compare
Source](https://github.com/mermaid-js/mermaid/compare/v10.7.0...v10.8.0)

### v10.8.0

#### Features

<img width="375" alt="image"
src="https://github.com/mermaid-js/mermaid/assets/5837277/c17405fb-2a06-4f7c-9c77-5eaba6c76747">

- Adding new diagram type - Block Diagram by
[@&#8203;knsv](https://github.com/knsv) in
[https://github.com/mermaid-js/mermaid/pull/5221](https://github.com/mermaid-js/mermaid/pull/5221)

- Feature/5114 add parallel commit config by
[@&#8203;mathbraga](https://github.com/mathbraga) in
[https://github.com/mermaid-js/mermaid/pull/5161](https://github.com/mermaid-js/mermaid/pull/5161)

- Changes to Gantt Parsers to allow hashes and semicolons to titles,
sections, and task data. by
[@&#8203;FutzMonitor](https://github.com/FutzMonitor) in
[https://github.com/mermaid-js/mermaid/pull/5095](https://github.com/mermaid-js/mermaid/pull/5095)

- Feature/4653 add actor-top class to sequence diagram by
[@&#8203;Ronid1](https://github.com/Ronid1) in
[https://github.com/mermaid-js/mermaid/pull/5241](https://github.com/mermaid-js/mermaid/pull/5241)

#### Documentation

- Updated gantt chart docs to show all config options by
[@&#8203;murdoa](https://github.com/murdoa) in
[https://github.com/mermaid-js/mermaid/pull/5192](https://github.com/mermaid-js/mermaid/pull/5192)
- Contribution documentation improvements by
[@&#8203;nirname](https://github.com/nirname) in
[https://github.com/mermaid-js/mermaid/pull/5132](https://github.com/mermaid-js/mermaid/pull/5132)
- Update flowchart.md - how to use font-awesome
[#&#8203;5195](https://github.com/mermaid-js/mermaid/issues/5195) by
[@&#8203;arukiidou](https://github.com/arukiidou) in
[https://github.com/mermaid-js/mermaid/pull/5196](https://github.com/mermaid-js/mermaid/pull/5196)
- Add more detailed docs for Gantt tasks by
[@&#8203;sorenisanerd](https://github.com/sorenisanerd) in
[https://github.com/mermaid-js/mermaid/pull/5194](https://github.com/mermaid-js/mermaid/pull/5194)
- Docs/4974 reorder integration links by
[@&#8203;Ronid1](https://github.com/Ronid1) in
[https://github.com/mermaid-js/mermaid/pull/5066](https://github.com/mermaid-js/mermaid/pull/5066)
- docs: fix swimm link by
[@&#8203;Yokozuna59](https://github.com/Yokozuna59) in
[https://github.com/mermaid-js/mermaid/pull/5219](https://github.com/mermaid-js/mermaid/pull/5219)
- Update Slack community links to Discord by
[@&#8203;Olegt0rr](https://github.com/Olegt0rr) in
[https://github.com/mermaid-js/mermaid/pull/5225](https://github.com/mermaid-js/mermaid/pull/5225)
- Docs: Mermaid chart updates by
[@&#8203;huynhicode](https://github.com/huynhicode) in
[https://github.com/mermaid-js/mermaid/pull/5232](https://github.com/mermaid-js/mermaid/pull/5232)
- Fix typos in timeline syntax samples by
[@&#8203;sblom](https://github.com/sblom) in
[https://github.com/mermaid-js/mermaid/pull/5139](https://github.com/mermaid-js/mermaid/pull/5139)

#### Bug fixes

- Bug/5059 fix external connection after updating edges by
[@&#8203;mathbraga](https://github.com/mathbraga) in
[https://github.com/mermaid-js/mermaid/pull/5127](https://github.com/mermaid-js/mermaid/pull/5127)
- \[Fix] Sequence diagram actor menu popup by
[@&#8203;vitorsss](https://github.com/vitorsss) in
[https://github.com/mermaid-js/mermaid/pull/5160](https://github.com/mermaid-js/mermaid/pull/5160)
- fix: Dompurify Hooks by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5236](https://github.com/mermaid-js/mermaid/pull/5236)
- Accurate pie chart labeling for text alignment by
[@&#8203;JenningsWilliam](https://github.com/JenningsWilliam) in
[https://github.com/mermaid-js/mermaid/pull/5141](https://github.com/mermaid-js/mermaid/pull/5141)
- fix: Redirect of old URLs by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5250](https://github.com/mermaid-js/mermaid/pull/5250)
- Fixed Typo in ErrorRenderer.ts by
[@&#8203;FutzMonitor](https://github.com/FutzMonitor) in
[https://github.com/mermaid-js/mermaid/pull/5256](https://github.com/mermaid-js/mermaid/pull/5256)

#### Chores

- Revert "Revert 5041 feature/4935 subgraph title margin config option"
by [@&#8203;mathbraga](https://github.com/mathbraga) in
[https://github.com/mermaid-js/mermaid/pull/5205](https://github.com/mermaid-js/mermaid/pull/5205)
- build(deps-dev): bump follow-redirects from 1.15.2 to 1.15.5 by
[@&#8203;dependabot](https://github.com/dependabot) in
[https://github.com/mermaid-js/mermaid/pull/5200](https://github.com/mermaid-js/mermaid/pull/5200)
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://github.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/5150](https://github.com/mermaid-js/mermaid/pull/5150)
- E2E Image comparison by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5208](https://github.com/mermaid-js/mermaid/pull/5208)
- E2E test by [@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5210](https://github.com/mermaid-js/mermaid/pull/5210)
- Optimise caching of test results by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5213](https://github.com/mermaid-js/mermaid/pull/5213)
- Update update-browserlist.yml to fix deprecation and action fails by
[@&#8203;Abrifq](https://github.com/Abrifq) in
[https://github.com/mermaid-js/mermaid/pull/5151](https://github.com/mermaid-js/mermaid/pull/5151)
- UpdateCypress by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5228](https://github.com/mermaid-js/mermaid/pull/5228)
- Use node v20 by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5248](https://github.com/mermaid-js/mermaid/pull/5248)
- Convert Mindmap to TS by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5247](https://github.com/mermaid-js/mermaid/pull/5247)
- chore: Add interface naming Convention by
[@&#8203;sidharthv96](https://github.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/5254](https://github.com/mermaid-js/mermaid/pull/5254)

#### New Contributors

- [@&#8203;murdoa](https://github.com/murdoa) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5192](https://github.com/mermaid-js/mermaid/pull/5192)
- [@&#8203;arukiidou](https://github.com/arukiidou) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5196](https://github.com/mermaid-js/mermaid/pull/5196)
- [@&#8203;sorenisanerd](https://github.com/sorenisanerd) made their
first contribution in
[https://github.com/mermaid-js/mermaid/pull/5194](https://github.com/mermaid-js/mermaid/pull/5194)
- [@&#8203;Ronid1](https://github.com/Ronid1) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5066](https://github.com/mermaid-js/mermaid/pull/5066)
- [@&#8203;Olegt0rr](https://github.com/Olegt0rr) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5225](https://github.com/mermaid-js/mermaid/pull/5225)
- [@&#8203;vitorsss](https://github.com/vitorsss) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5160](https://github.com/mermaid-js/mermaid/pull/5160)
- [@&#8203;sblom](https://github.com/sblom) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/5139](https://github.com/mermaid-js/mermaid/pull/5139)
- [@&#8203;JenningsWilliam](https://github.com/JenningsWilliam) made
their first contribution in
[https://github.com/mermaid-js/mermaid/pull/5141](https://github.com/mermaid-js/mermaid/pull/5141)

**Full Changelog**:
mermaid-js/mermaid@v10.7.0...v10.8.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/levaintech/contented).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE1My4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant