mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-04 15:09:40 +00:00
LibWeb: Added HTMLLinkElement.as
(cherry picked from commit 2f4668edce2effb38563b9da229d00d3ba5dc508, manually amended to move `||` at the start of the line to appease clang-format)
This commit is contained in:
parent
5e4e39d84a
commit
928576e0ac
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(alt) \
|
||||||
__ENUMERATE_HTML_ATTRIBUTE(archive) \
|
__ENUMERATE_HTML_ATTRIBUTE(archive) \
|
||||||
__ENUMERATE_HTML_ATTRIBUTE(async) \
|
__ENUMERATE_HTML_ATTRIBUTE(async) \
|
||||||
|
__ENUMERATE_HTML_ATTRIBUTE(as) \
|
||||||
__ENUMERATE_HTML_ATTRIBUTE(autocomplete) \
|
__ENUMERATE_HTML_ATTRIBUTE(autocomplete) \
|
||||||
__ENUMERATE_HTML_ATTRIBUTE(autofocus) \
|
__ENUMERATE_HTML_ATTRIBUTE(autofocus) \
|
||||||
__ENUMERATE_HTML_ATTRIBUTE(autoplay) \
|
__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
|
// https://html.spec.whatwg.org/multipage/semantics.html#dom-link-rellist
|
||||||
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLLinkElement::rel_list()
|
JS::NonnullGCPtr<DOM::DOMTokenList> HTMLLinkElement::rel_list()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
||||||
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
||||||
String href() const { return get_attribute_value(HTML::AttributeNames::href); }
|
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();
|
JS::NonnullGCPtr<DOM::DOMTokenList> rel_list();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ interface HTMLLinkElement : HTMLElement {
|
||||||
[CEReactions, Reflect] attribute DOMString href;
|
[CEReactions, Reflect] attribute DOMString href;
|
||||||
[CEReactions, Reflect=crossorigin, Enumerated=CORSSettingsAttribute] attribute DOMString? crossOrigin;
|
[CEReactions, Reflect=crossorigin, Enumerated=CORSSettingsAttribute] attribute DOMString? crossOrigin;
|
||||||
[CEReactions, Reflect] attribute DOMString rel;
|
[CEReactions, Reflect] attribute DOMString rel;
|
||||||
[FIXME, CEReactions] attribute DOMString as;
|
[CEReactions] attribute DOMString as;
|
||||||
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
||||||
[CEReactions, Reflect] attribute DOMString media;
|
[CEReactions, Reflect] attribute DOMString media;
|
||||||
[CEReactions, Reflect] attribute DOMString integrity;
|
[CEReactions, Reflect] attribute DOMString integrity;
|
||||||
|
|
Loading…
Reference in a new issue