mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Added HTMLLinkElement.as
This commit is contained in:
parent
4b3e26c583
commit
2f4668edce
Notes:
sideshowbarker
2024-07-17 22:41:14 +09:00
Author: https://github.com/Hexeption Commit: https://github.com/LadybirdBrowser/ladybird/commit/2f4668edce Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/39 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/nico
5 changed files with 48 additions and 1 deletions
21
Base/res/html/misc/linkas.html
Normal file
21
Base/res/html/misc/linkas.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Link AS test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://fonts.googleapis.com/css?family=Roboto:400,700';
|
||||
link.as = 'style';
|
||||
|
||||
console.log("Link.as: " + link.as); // should be 'style'
|
||||
|
||||
link.as = 'uwu';
|
||||
|
||||
console.log("Link.as: " + link.as); // should be ''
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -25,6 +25,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(alt) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(archive) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(async) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(as) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(autocomplete) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(autofocus) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(autoplay) \
|
||||
|
|
|
@ -90,6 +90,29 @@ void HTMLLinkElement::inserted()
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#dom-link-as
|
||||
String HTMLLinkElement::as() const
|
||||
{
|
||||
String attribute_value = get_attribute_value(HTML::AttributeNames::as);
|
||||
|
||||
if (attribute_value.equals_ignoring_ascii_case("fetch"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("image"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("script"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("style"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("video"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("audio"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("track"sv) ||
|
||||
attribute_value.equals_ignoring_ascii_case("font"sv))
|
||||
return attribute_value.to_lowercase().release_value();
|
||||
|
||||
return String {};
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLLinkElement::set_as(String const& value)
|
||||
{
|
||||
return set_attribute(HTML::AttributeNames::as, move(value));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#dom-link-rellist
|
||||
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLLinkElement::rel_list()
|
||||
{
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
||||
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
||||
String href() const { return get_attribute_value(HTML::AttributeNames::href); }
|
||||
String as() const;
|
||||
WebIDL::ExceptionOr<void> set_as(String const&);
|
||||
|
||||
JS::NonnullGCPtr<DOM::DOMTokenList> rel_list();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ interface HTMLLinkElement : HTMLElement {
|
|||
[CEReactions, Reflect] attribute DOMString href;
|
||||
[CEReactions, Reflect=crossorigin, Enumerated=CORSSettingsAttribute] attribute DOMString? crossOrigin;
|
||||
[CEReactions, Reflect] attribute DOMString rel;
|
||||
[FIXME, CEReactions] attribute DOMString as;
|
||||
[CEReactions] attribute DOMString as;
|
||||
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
||||
[CEReactions, Reflect] attribute DOMString media;
|
||||
[CEReactions, Reflect] attribute DOMString integrity;
|
||||
|
|
Loading…
Reference in a new issue