mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 01:55:57 +08:00
FIX: ensures lightbox sends valid color to react-native (#22598)
Prior to this commit the `setSiteThemeColor` could mistakenly receive a color with a leading `#` which would cause an invalid color to be send to `postRNWebviewMessage` and would eventually cause a crash if we try to interpolate between this color and another.
This commit is contained in:
parent
56e792df9b
commit
ee3bdab61d
@ -6,7 +6,7 @@ export async function getSiteThemeColor() {
|
||||
}
|
||||
|
||||
export async function setSiteThemeColor(color = "000000") {
|
||||
const _color = `#${color}`;
|
||||
const _color = `#${color.replace(/^#*/, "")}`;
|
||||
|
||||
const siteThemeColor = document.querySelector('meta[name="theme-color"]');
|
||||
|
||||
|
@ -55,5 +55,15 @@ module(
|
||||
|
||||
querySelectorSpy.restore();
|
||||
});
|
||||
|
||||
test("invalid color given", async function (assert) {
|
||||
await setSiteThemeColor("##0000ff");
|
||||
|
||||
assert.strictEqual(
|
||||
document.querySelector('meta[name="theme-color"]').content,
|
||||
"#0000ff",
|
||||
"converts to a the correct theme color"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user