You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current Behavior
When a post is loaded and its template contains javascript, the javascript doesn't run until the post experiences an onupdate cycle.
This can be experienced with syntax-highlighted code blocks, but probably also other extensions.
Steps to Reproduce
Create post with code block
Refresh page
See post is not highlighted
This can probably be reproduced with other community extensions. I think the code block is the only one from core with javascript in the template itself.
Expected Behavior
Javascript should run during the first render
Screenshots
Environment
Flarum version: beta 14
Website URL: tested locally
Possible Solution
We need to call the code from onupdate in oncreate. Previously that code ran in config without any regard to isInitialized.
While we're at it, I think we should also call super.onupdate with a vnode parameter. If an extension was to extend Post.prototype.onupdate, they wouldn't be able to access vnode because CommentPost forgets to pass it up.
Unfortunately this doesn't fix the issue. From local testing, code blocks are highlighted during editing and not on a regular page because its shown in the ComposerPostPreview component. This chunk of code does nothing in beta 14 (which is probably the issue)
Bug Report
Current Behavior
When a post is loaded and its template contains javascript, the javascript doesn't run until the post experiences an onupdate cycle.
This can be experienced with syntax-highlighted code blocks, but probably also other extensions.
Steps to Reproduce
This can probably be reproduced with other community extensions. I think the code block is the only one from core with javascript in the template itself.
Expected Behavior
Javascript should run during the first render
Screenshots
Environment
Possible Solution
We need to call the code from
onupdate
inoncreate
. Previously that code ran inconfig
without any regard toisInitialized
.Beta 13 code
https://github.com/flarum/core/blob/fd371c1203439810af8f6814cdff402faebf4126/js/src/forum/components/CommentPost.js#L57-L72
Current code
https://github.com/flarum/core/blob/c9a04fe009abf474b39f562e9d4bf13c5ecf25c8/js/src/forum/components/CommentPost.js#L59-L74
While we're at it, I think we should also call
super.onupdate
with avnode
parameter. If an extension was to extendPost.prototype.onupdate
, they wouldn't be able to accessvnode
becauseCommentPost
forgets to pass it up.Additional Context
Reported by RebelCoderRU here https://discuss.flarum.org/d/25227-code-highlighting-not-working-properly-on-beta-14
The text was updated successfully, but these errors were encountered: