mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
wire up CSSStyleSheet.ownerNode to the style element
This commit is contained in:
@@ -38,6 +38,11 @@
|
||||
testing.expectEqual(true, tempStyle.sheet instanceof CSSStyleSheet);
|
||||
document.head.removeChild(tempStyle);
|
||||
testing.expectEqual(null, tempStyle.sheet);
|
||||
|
||||
// ownerNode points back to the style element
|
||||
const ownStyle = document.createElement('style');
|
||||
document.head.appendChild(ownStyle);
|
||||
testing.expectEqual(true, ownStyle.sheet.ownerNode === ownStyle);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const std = @import("std");
|
||||
const js = @import("../../js/js.zig");
|
||||
const Page = @import("../../Page.zig");
|
||||
const Element = @import("../Element.zig");
|
||||
const CSSRuleList = @import("CSSRuleList.zig");
|
||||
const CSSRule = @import("CSSRule.zig");
|
||||
|
||||
@@ -11,14 +12,18 @@ _title: []const u8 = "",
|
||||
_disabled: bool = false,
|
||||
_css_rules: ?*CSSRuleList = null,
|
||||
_owner_rule: ?*CSSRule = null,
|
||||
_owner_node: ?*Element = null,
|
||||
|
||||
pub fn init(page: *Page) !*CSSStyleSheet {
|
||||
return page._factory.create(CSSStyleSheet{});
|
||||
}
|
||||
|
||||
pub fn getOwnerNode(self: *const CSSStyleSheet) ?*CSSStyleSheet {
|
||||
_ = self;
|
||||
return null;
|
||||
pub fn initWithOwner(owner: *Element, page: *Page) !*CSSStyleSheet {
|
||||
return page._factory.create(CSSStyleSheet{ ._owner_node = owner });
|
||||
}
|
||||
|
||||
pub fn getOwnerNode(self: *const CSSStyleSheet) ?*Element {
|
||||
return self._owner_node;
|
||||
}
|
||||
|
||||
pub fn getHref(self: *const CSSStyleSheet) ?[]const u8 {
|
||||
|
||||
@@ -92,7 +92,7 @@ pub fn getSheet(self: *Style, page: *Page) !?*CSSStyleSheet {
|
||||
}
|
||||
|
||||
if (self._sheet) |sheet| return sheet;
|
||||
const sheet = try CSSStyleSheet.init(page);
|
||||
const sheet = try CSSStyleSheet.initWithOwner(self.asElement(), page);
|
||||
self._sheet = sheet;
|
||||
return sheet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user