Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

FIX: prefers textContent over innerText #111

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/javascripts/initializers/discourse-math-mathjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function decorate(elem, isPreview) {

const mathScript = document.createElement("script");
mathScript.type = type;
mathScript.innerText = elem.innerText;
mathScript.innerText = elem.textContent;

const mathWrapper = document.createElement(tag);
mathWrapper.classList.add(classList.split(" "));
Expand Down
23 changes: 23 additions & 0 deletions spec/system/post_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

RSpec.describe "Discourse Math - post", type: :system do
fab!(:current_user) { Fabricate(:admin) }

before do
SiteSetting.discourse_math_enabled = true
sign_in(current_user)
end

it "works with details" do
post =
create_post(
user: current_user,
raw: "This is maths:\n\n[details='math']\n$E=mc^2$\n[/details]",
)
visit(post.topic.url)

find("#post_1 details").click

expect(page).to have_selector("#MJXc-Node-6", text: "2")
end
end