Commit 2b355c9
2 files changed
+5
-3
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
347 | 347 |
| |
348 | 348 |
| |
349 | 349 |
| |
350 |
| - | |
351 |
| - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
352 | 354 |
| |
353 | 355 |
| |
354 | 356 |
| |
|
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
10 commit comments
LeaVerou commentedon Jul 2, 2021
I've actually ran into issues of double highlighting with regular Prism too and had to employ hacks to heuristically detect if highlighting had already ran. I wonder if this is something we need to fix more centrally.
RunDevelopment commentedon Jul 2, 2021
We certainly do.
The underlying problem here is that hooks aren't removed when the language gets reloaded. This leads to the same hook being executed multiple times.
To fix this, we have to figure out how to properly unload plugins, a long-standing issue (#459).
RunDevelopment commentedon Jul 2, 2021
I think our best shot for solving #459 will be the new dependency system (#2880) planned for v2.0. With some relatively minor additions, we can include hooks into that system. This gives us enough information to let Prism load and unload hooks automatically.
LeaVerou commentedon Jul 2, 2021
This problem is present even when no language gets reloaded, just with simple stock Prism included via a script tag, if you just pass it the same element to highlight twice.
RunDevelopment commentedon Jul 2, 2021
Oh, that's what you meant. You had an issue with Keep Markup, right? Yeah, that definitely a problem too.
mAAdhaTTah commentedon Jul 2, 2021
Once we start on v2 & drop IE11 support, we could hold onto already-highlighted nodes in a
Set
orWeakSet
so we can tag them as already-highlighted.RunDevelopment commentedon Jul 2, 2021
IE11 does support most of
Set
andWeakMap
. So whatever solution you have in mind, we could probably do it right now.LeaVerou commentedon Jul 2, 2021
That wouldn't work, because we still want to be able to overwrite a node's contents and highlight it again.
mAAdhaTTah commentedon Jul 2, 2021
I'm not 100% clear on the larger problem, but I was just thinking Set/WeakSet to solve the more direct problem, tracking whether highlighting already ran. The plugins that have problems when reloading can track to avoid re-highlighting, if that's something we want to do.
RunDevelopment commentedon Jul 2, 2021
That's all plugins. This is a fundamental problem with the way we reload components. I don't think tracking already highlighted elements will help.