altv-issues
altv-issues copied to clipboard
RmlElement is missing TextNode methods.
Description of the problem
There doesn't seem to be a method for getting and setting value of the Text on text node created using document.createTextNode.
Reproduction steps
const document = new alt.RmlDocument("foo.rml");
const fooText = document.createTextNode("foo");
if (fooText.innerRML !== "foo") {
fooText.innerRML = "foo";
}
document.body.appendChild(fooText);
<rml>
<head>
<title>Testing RML</title>
</head>
<body></body>
</rml>
Expected behaviour
fooText.innerRML to have value "foo" after creating text node, but it's empty instead. When setting fooText.innerRML to "foo", the game displays duplicated values. e.g. text node was created with value "bar" and has it's innerRML set to "bar" as well.
Additional context
Topic in #scripting-questions: https://discord.com/channels/371265202378899476/1128207399774339093
- Both document.createElement and document.createTextNode returns RmlElement object.
- RmlUi docs seems to have set/get text methods for TextNode.
- They're not present on RmlElement.
Operating system
N/A
Version
15.0-dev346
Crashdump ID
No response
Reproduction tested
- [X] I confirm that I have made sure that this issue is also present on the newest dev version
Closing this issue because it's unlikely to be fixed and good enough workarounds exist.
The one I use, is setting text value to the RmlElement meta, so I can access it later:
function createTextNode(document: alt.RmlDocument, text: string) {
const node = document.createTextNode(text);
node.meta.text = text;
return node;
}
I don't see why this wouldn't be fixed, the element is just a Rml::ElementText which has GetText and SetText methods which can be easily exposed to the API.