Procházet zdrojové kódy

LibWeb: Allow event handler attributes on HTMLLinkElement

We were neglecting to set up event handlers for these due to a missing
call to the base class in HTMLLinkElement::parse_attribute().
Andreas Kling před 2 roky
rodič
revize
c50ce2030d

+ 1 - 0
Tests/LibWeb/Text/expected/link-element-onload-attribute.txt

@@ -0,0 +1 @@
+link element onload

+ 9 - 0
Tests/LibWeb/Text/input/link-element-onload-attribute.html

@@ -0,0 +1,9 @@
+<script src="include.js"></script>
+<script>
+    let link = document.createElement("link");
+    link.setAttribute("rel", "preload");
+    link.setAttribute("href", "valid.css");
+    link.setAttribute("as", "style");
+    link.setAttribute("onload", "println('link element onload')");
+    document.head.appendChild(link);
+</script>

+ 2 - 0
Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp

@@ -79,6 +79,8 @@ bool HTMLLinkElement::has_loaded_icon() const
 
 void HTMLLinkElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
 {
+    HTMLElement::parse_attribute(name, value);
+
     // 4.6.7 Link types - https://html.spec.whatwg.org/multipage/links.html#linkTypes
     if (name == HTML::AttributeNames::rel) {
         m_relationship = 0;