Skip to content

Commit

Permalink
LibWeb: Do includes_properties_from_invalidation_set() for :link & co
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Feb 9, 2025
1 parent 9589386 commit 76bbac8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Libraries/LibWeb/DOM/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <LibWeb/HTML/CustomElements/CustomElementReactionNames.h>
#include <LibWeb/HTML/CustomElements/CustomElementRegistry.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/HTMLBodyElement.h>
#include <LibWeb/HTML/HTMLButtonElement.h>
#include <LibWeb/HTML/HTMLFieldSetElement.h>
Expand Down Expand Up @@ -72,6 +74,7 @@
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/SVG/SVGAElement.h>
#include <LibWeb/Selection/Selection.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/DOMException.h>
Expand Down Expand Up @@ -1198,6 +1201,15 @@ bool Element::includes_properties_from_invalidation_set(CSS::InvalidationSet con
// - FIXME: textarea elements that have a placeholder attribute whose value is currently being presented to the user.
return false;
}
case CSS::PseudoClass::AnyLink:
case CSS::PseudoClass::Link:
case CSS::PseudoClass::LocalLink: {
if (!is<HTML::HTMLAnchorElement>(*this) && !is<HTML::HTMLAreaElement>(*this) && !is<SVG::SVGAElement>(*this))
return false;
if (!has_attribute(HTML::AttributeNames::href))
return false;
return true;
}
default:
VERIFY_NOT_REACHED();
}
Expand Down
13 changes: 13 additions & 0 deletions Tests/LibWeb/Crash/CSS/link-pseudo-class-invalidation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<style>
ul#mylist a:link { }
ul#mylist a:any-link { }
ul#mylist a:local-link { }
</style>
<script>
let o = document.createElement("div");
o.offsetWidth;
</script>
<body>
<ul id="mylist"></ul>
</body>

0 comments on commit 76bbac8

Please sign in to comment.