mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibWeb: Implement window.location.port
This returns the port of the current document's URL. :^)
This commit is contained in:
parent
407cf04884
commit
74b88a8156
2 changed files with 8 additions and 0 deletions
|
@ -29,6 +29,7 @@ void LocationObject::initialize(JS::GlobalObject& global_object)
|
||||||
define_native_accessor("hash", hash_getter, {}, attr);
|
define_native_accessor("hash", hash_getter, {}, attr);
|
||||||
define_native_accessor("search", search_getter, {}, attr);
|
define_native_accessor("search", search_getter, {}, attr);
|
||||||
define_native_accessor("protocol", protocol_getter, {}, attr);
|
define_native_accessor("protocol", protocol_getter, {}, attr);
|
||||||
|
define_native_accessor("port", port_getter, {}, attr);
|
||||||
|
|
||||||
define_native_function("reload", reload, 0, JS::Attribute::Enumerable);
|
define_native_function("reload", reload, 0, JS::Attribute::Enumerable);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +111,12 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::protocol_getter)
|
||||||
return JS::js_string(vm, builder.to_string());
|
return JS::js_string(vm, builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(LocationObject::port_getter)
|
||||||
|
{
|
||||||
|
auto& window = static_cast<WindowObject&>(global_object);
|
||||||
|
return JS::Value(window.impl().associated_document().url().port_or_default());
|
||||||
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||||
{
|
{
|
||||||
auto& window = static_cast<WindowObject&>(global_object);
|
auto& window = static_cast<WindowObject&>(global_object);
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(hash_getter);
|
JS_DECLARE_NATIVE_FUNCTION(hash_getter);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(search_getter);
|
JS_DECLARE_NATIVE_FUNCTION(search_getter);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(protocol_getter);
|
JS_DECLARE_NATIVE_FUNCTION(protocol_getter);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(port_getter);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue