1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[js] dir setter

This commit is contained in:
Witold Filipczyk 2021-06-03 13:51:59 +02:00
parent 7a65feb323
commit fc60848d64
2 changed files with 20 additions and 0 deletions

View File

@ -1420,6 +1420,18 @@ element_set_property_dir(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());
if (value == "ltr" || value == "rtl" || value == "auto") {
el->set_attribute("dir", value);
}
return true;
}

View File

@ -14,7 +14,15 @@ function aa()
alert('ble ' + document.getElementById('ble').dir);
alert('bb ' + document.getElementById('bb').dir);
}
function bb()
{
document.getElementById('blabla').dir = 'ltr';
alert('blabla ' + document.getElementById('blabla').dir);
}
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">blabla.dir = ltr</button>
</body>
</html>