mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:37:34 +00:00
LibWeb: Add Element.id property to the bindings
This commit is contained in:
parent
0f7bcd4111
commit
c1c56b1131
2 changed files with 17 additions and 0 deletions
|
@ -39,6 +39,7 @@ ElementWrapper::ElementWrapper(Element& element)
|
||||||
: NodeWrapper(element)
|
: NodeWrapper(element)
|
||||||
{
|
{
|
||||||
put_native_property("innerHTML", inner_html_getter, inner_html_setter);
|
put_native_property("innerHTML", inner_html_getter, inner_html_setter);
|
||||||
|
put_native_property("id", id_getter, id_setter);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementWrapper::~ElementWrapper()
|
ElementWrapper::~ElementWrapper()
|
||||||
|
@ -77,5 +78,18 @@ void ElementWrapper::inner_html_setter(JS::Interpreter& interpreter, JS::Value v
|
||||||
impl->set_inner_html(value.to_string());
|
impl->set_inner_html(value.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS::Value ElementWrapper::id_getter(JS::Interpreter& interpreter)
|
||||||
|
{
|
||||||
|
if (auto* impl = impl_from(interpreter))
|
||||||
|
return JS::js_string(interpreter.heap(), impl->attribute("id"));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElementWrapper::id_setter(JS::Interpreter& interpreter, JS::Value value)
|
||||||
|
{
|
||||||
|
if (auto* impl = impl_from(interpreter))
|
||||||
|
impl->set_attribute("id", value.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,9 @@ private:
|
||||||
|
|
||||||
static JS::Value inner_html_getter(JS::Interpreter&);
|
static JS::Value inner_html_getter(JS::Interpreter&);
|
||||||
static void inner_html_setter(JS::Interpreter&, JS::Value);
|
static void inner_html_setter(JS::Interpreter&, JS::Value);
|
||||||
|
|
||||||
|
static JS::Value id_getter(JS::Interpreter&);
|
||||||
|
static void id_setter(JS::Interpreter&, JS::Value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue