From fc60848d640f1f9b9a4950a4ad9e5e616fcd104e Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 3 Jun 2021 13:51:59 +0200 Subject: [PATCH] [js] dir setter --- src/ecmascript/spidermonkey/element.c | 12 ++++++++++++ test/ecmascript/dir.html | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/ecmascript/spidermonkey/element.c b/src/ecmascript/spidermonkey/element.c index b483584c..cf9e8a4f 100644 --- a/src/ecmascript/spidermonkey/element.c +++ b/src/ecmascript/spidermonkey/element.c @@ -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; } diff --git a/test/ecmascript/dir.html b/test/ecmascript/dir.html index 4fee3342..433f82c8 100644 --- a/test/ecmascript/dir.html +++ b/test/ecmascript/dir.html @@ -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); +} + +