spoilers: Adjust HTML source order to match presentation.

This commit is contained in:
Karl Stolley
2024-04-12 14:53:48 -05:00
committed by Tim Abbott
parent a49111c89a
commit f2a1c96940
2 changed files with 10 additions and 14 deletions

View File

@@ -270,7 +270,7 @@ export const update_elements = ($content: JQuery): void => {
// Add the expand/collapse button to spoiler blocks // Add the expand/collapse button to spoiler blocks
const toggle_button_html = const toggle_button_html =
'<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>'; '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
$(this).prepend($(toggle_button_html)); $(this).append($(toggle_button_html));
}); });
// Display the view-code-in-playground and the copy-to-clipboard button inside the div.codehilite element, // Display the view-code-in-playground and the copy-to-clipboard button inside the div.codehilite element,

View File

@@ -490,9 +490,9 @@ run_test("spoiler-header", () => {
const $content = get_content_element(); const $content = get_content_element();
const $header = $.create("div.spoiler-header"); const $header = $.create("div.spoiler-header");
$content.set_find_results("div.spoiler-header", $array([$header])); $content.set_find_results("div.spoiler-header", $array([$header]));
let $prepended; let $appended;
$header.prepend = ($element) => { $header.append = ($element) => {
$prepended = $element; $appended = $element;
}; };
// Test that the show/hide button gets added to a spoiler header. // Test that the show/hide button gets added to a spoiler header.
@@ -502,7 +502,7 @@ run_test("spoiler-header", () => {
$header.html(label); $header.html(label);
rm.update_elements($content); rm.update_elements($content);
assert.equal(label, $header.html()); assert.equal(label, $header.html());
assert.equal($prepended.selector, toggle_button_html); assert.equal($appended.selector, toggle_button_html);
}); });
run_test("spoiler-header-empty-fill", () => { run_test("spoiler-header-empty-fill", () => {
@@ -510,13 +510,9 @@ run_test("spoiler-header-empty-fill", () => {
const $content = get_content_element(); const $content = get_content_element();
const $header = $.create("div.spoiler-header"); const $header = $.create("div.spoiler-header");
$content.set_find_results("div.spoiler-header", $array([$header])); $content.set_find_results("div.spoiler-header", $array([$header]));
let $appended; const $appended = [];
$header.append = ($element) => { $header.append = ($element) => {
$appended = $element; $appended.push($element);
};
let $prepended;
$header.prepend = ($element) => {
$prepended = $element;
}; };
// Test that an empty header gets the default text applied (through i18n filter). // Test that an empty header gets the default text applied (through i18n filter).
@@ -524,9 +520,9 @@ run_test("spoiler-header-empty-fill", () => {
'<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>'; '<span class="spoiler-button" aria-expanded="false"><span class="spoiler-arrow"></span></span>';
$header.empty(); $header.empty();
rm.update_elements($content); rm.update_elements($content);
assert.equal($appended.selector, "<p>"); assert.equal($appended[0].selector, "<p>");
assert.equal($appended.text(), $t({defaultMessage: "Spoiler"})); assert.equal($appended[0].text(), $t({defaultMessage: "Spoiler"}));
assert.equal($prepended.selector, toggle_button_html); assert.equal($appended[1].selector, toggle_button_html);
}); });
function assert_clipboard_setup() { function assert_clipboard_setup() {