CSS::DOM::Rule(3pm)
π CSS::DOM::Rule β the vibe π
okay bestie, so you wanna know about CSS::DOM::Rule? it's the CSS rule class for CSS::DOM, and it's part of the User Contributed Perl Documentation collection. yes, we're doing perldoc today, and honestly? we ate. π
Version: 0.17 β¨
π SYNOPSIS π
like, here's the whole vibe in code, no notes:
use CSS::DOM::Rule ':all'; # import constants
use CSS::DOM;
$sheet = new CSS::DOM;
$sheet->insertRule('bla blah blah {}');
$rule = $sheet->cssRules->[0];
$rule->type; # STYLE_RULE
$rule->cssText; # 'bla blah blah {}' or similar
$rule->cssText('p { margin: 0 }'); # replace it
$rule->parentStyleSheet; # $sheet
see how it all justβ¦ flows? that's the energy we're bringing. π¦
πΈ DESCRIPTION πΈ
so this module is the one that hands you the CSS rule class for CSS::DOM. it implements the CSSRule and CSSUnknownRule DOM interfaces. that's it, that's the whole job, and it does it flawlessly. π
β¨ METHODS β¨
π§ Constructor
okay so here's the thing β only call the constructor on this class if you want to make an 'unknown' rule. if you want literally any other type of rule, you gotta call the constructor on the specific subclass instead. and ngl, most of the time you don't even need to call it directly anyway (peep CSS::DOM's "parse" and "insertRule" methods, they handle it). but just in case you're feeling brave, here it is:
new CSS::DOM::Rule $parent; # unknown rule
require CSS::DOM::Rule::Style
new CSS::DOM::Rule::Style $parent;
# etc.
and <lavender>$parent</lavender>? that's the parent rule if your rule is nested, or the parent style sheet if it's not. either way, it's the thing that owns it. π«Ά
π Object Methods
typeβ hands you one of the constants listed down below that says what kind of rule this is. simple. iconic.cssTextβ gives you this rule's CSS code back. but wait, there's more: if you pass it an argument, that argument gets parsed as the new CSS code for this rule (so it replaces all the existing data), and then you get the old value returned to you. cute, right? π
β οΈ but fr fr β this method will die if the replacement CSS code you gave it creates a different type of rule. so don't try it. or do, but know the consequences. π
parentStyleSheetβ returns the style sheet that this rule belongs to. that's the whole thing. πparentRuleβ returns the rule's parent rule if there is one, otherwise it returns an empty list. and heads up: there's only a parent rule if this one is nested, like, say, inside a media rule. iykyk. π
π EXPORTS π
these constants β which tell you the type of the rule β get exported on request (you can ask for them one at a time, or just grab them all with the ':all' tag):
UNKNOWN_RULE
STYLE_RULE
CHARSET_RULE
IMPORT_RULE
MEDIA_RULE
FONT_FACE_RULE
PAGE_RULE
all seven of them, all accounted for, no skips. periodt. π
π SEE ALSO π
go read these too, bestie, they're all part of the family:
CSS::DOMCSS::DOM::Rule::StyleCSS::DOM::Rule::MediaCSS::DOM::Rule::PageCSS::DOM::Rule::Import
and that's the whole page!! this one came to you from perl v5.36.0, dated 2023-08-02, and it's filed under CSS::DOM::Rule(3pm). ty for coming to my ted talk, now go write some CSS from Perl like the main character you are πβ¨π¦
π¦ where this page comes from
- debian trixie: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms