mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +00:00
dispatch a load event when href set for Link element
Also add `lazy-href-set` test.
This commit is contained in:
@@ -69,3 +69,18 @@
|
|||||||
testing.eventually(() => testing.expectEqual(false, fired));
|
testing.eventually(() => testing.expectEqual(false, fired));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id="lazy-href-set">
|
||||||
|
{
|
||||||
|
let result = false;
|
||||||
|
const link = document.createElement("link");
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
link.onload = () => result = true;
|
||||||
|
// Append to DOM,
|
||||||
|
document.head.appendChild(link);
|
||||||
|
// then set href.
|
||||||
|
link.href = 'https://lightpanda.io/opensource-browser/15';
|
||||||
|
|
||||||
|
testing.eventually(() => testing.expectEqual(true, result));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -50,7 +50,12 @@ pub fn getHref(self: *Link, page: *Page) ![]const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn setHref(self: *Link, value: []const u8, page: *Page) !void {
|
pub fn setHref(self: *Link, value: []const u8, page: *Page) !void {
|
||||||
try self.asElement().setAttributeSafe(comptime .wrap("href"), .wrap(value), page);
|
const element = self.asElement();
|
||||||
|
try element.setAttributeSafe(comptime .wrap("href"), .wrap(value), page);
|
||||||
|
|
||||||
|
if (element.asNode().isConnected()) {
|
||||||
|
try page.linkAddedCallback(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getRel(self: *Link) []const u8 {
|
pub fn getRel(self: *Link) []const u8 {
|
||||||
|
|||||||
Reference in New Issue
Block a user