1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

[js] lang setter

This commit is contained in:
Witold Filipczyk 2021-06-03 14:01:54 +02:00
parent 70cd635ef3
commit 4270cb3125
2 changed files with 33 additions and 1 deletions

View File

@ -1539,10 +1539,17 @@ element_set_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = JS_GetPrivate(hobj);
if (!el) {
return true;
}
std::string value = JS_EncodeString(ctx, args[0].toString());
el->set_attribute("lang", value);
return true;
}
static bool
element_set_property_outerHtml(JSContext *ctx, unsigned int argc, JS::Value *vp)
{

25
test/ecmascript/lang.html Normal file
View File

@ -0,0 +1,25 @@
<html>
<body>
<a href="/home">BBB</a>
<b id="aaaa" lang="en">bbb</b>
<a id="blabla" href="/">
<b>AAA</b><u id="ble" title="test">UUU</u>AAAAAAA
</a>
<a id="bb" href="/">BB</a>
<script>
function aa()
{
alert(document.getElementById('aaaa').lang);
}
function bb()
{
document.getElementById('aaaa').lang = 'pl';
return aa();
}
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">Set lang to pl</button>
</body>
</html>