BUG: Fix crafted names with characters larger than /u+FFFF being invalid

This commit is contained in:
bananarama92 2025-03-20 17:23:43 +01:00
parent 4a7e328da6
commit 2f88d178f7
No known key found for this signature in database
GPG key ID: E83C7D3B5DA36248

View file

@ -421,7 +421,7 @@ var CraftingEventListeners = {
/**
* @private
* @type {(this: HTMLTextAreaElement, ev: Event) => void}
* @type {(this: HTMLTextAreaElement | HTMLInputElement, ev: Event) => void}
*/
_InputDescription: function _InputDescription() {
this.setCustomValidity(this.value.match(this.dataset.pattern) ? "" : "patternMismatch");
@ -1097,9 +1097,15 @@ function CraftingLoad() {
children: [
{ tag: "span", children: [TextGet("EnterName")] },
{
// NOTE: Perform the pattern checking via JS as there are differences in how plain JS `RegExp` and `HTMLInputElement.pattern`
// handle their pattern matching with characters larger than /u+FFFF
tag: "input",
attributes: { id: CraftingID.nameInput, type: "input", maxLength: "30", size: 0, pattern: CraftingDescription.Pattern.source },
eventListeners: { change: CraftingEventListeners._ChangeName },
attributes: { id: CraftingID.nameInput, type: "input", maxLength: "30", size: 0 },
dataAttributes: { pattern: CraftingDescription.Pattern.source },
eventListeners: {
change: CraftingEventListeners._ChangeName,
input: CraftingEventListeners._InputDescription,
},
},
],
},