CSS::D...::Media(3pm)

πŸ“¦
version 0.17 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CSS::D...::Media(3pm) β€” like, the whole manual but make it cute

okay bestie, so this is CSS::DOM::Rule::Media β€” the CSS @media rule class for CSS::DOM. Yes it lives in a file called CSS::D...::Media(3pm) because someone at the terminal decided to abbreviate, and honestly? iconic behaviour. Anyway.


✨ NAME ✨

CSS::DOM::Rule::Media β€” the CSS @media rule class for CSS::DOM. That's it, that's the name, she's simple and she serves πŸ’…

🌸 VERSION 🌸

Version 0.17 β€” vintage but thriving, no cap.

πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's how you actually use her:

use CSS::DOM;
my $media_rule = CSS::DOM->parse(
    '@media print { body { background: none } }'
)->cssRules->[0];

# OR:
use CSS::DOM::Rule::Media;
my $media_rule = new CSS::DOM::Rule::Media $parent;
push @{$media_rule->media}, 'print';
$media_rule->insertRule('body { background: none }')

two whole ways to get your @media rule and both of them eat, fr fr. πŸ“

πŸ‘‘ DESCRIPTION πŸ‘‘

This module implements CSS @media rules for CSS::DOM. It inherits from CSS::DOM::Rule and implements the CSSMediaRule DOM interface. So it's giving legacy DOM energy but make it Perl. Inheritance? Slay. Interface? Also slay. ✨

πŸŽ€ METHODS πŸŽ€

media

Returns the MediaList associated with the @media rule β€” or, plot twist, a plain list if you're in list context. This defaults to an empty list btw, so don't come for her if she's quiet at first.

Pro tip from the original text, verbatim energy: you can pass a comma-delimited string to the MediaList's "mediaText" method to set it. Comma-delimited. Yes. That's the move. 🫢

cssRules

In scalar context, this returns a CSS::DOM::RuleList object β€” which is literally just a blessed array reference, humble queen β€” full of CSS::DOM::Rule objects. In list context it returns a list. Context is everything bestie, always has been. πŸ’œ

insertRule ( $css_code, $index )

Parses the rule contained in the $css_code, inserting it into the @media rule's list of subrules at the given $index. So you hand her CSS as a string, you tell her where, and she just... does it. Main character energy. πŸ”₯

deleteRule ( $index )

Deletes the rule at the given $index. That's the whole thing. Gone. Not me being emotional about it. 😭

🌈 SEE ALSO 🌈

the girlies you should also be reading, iykyk:

  • CSS::DOM
  • CSS::DOM::Rule
  • CSS::DOM::MediaList

πŸ’« the sign-off πŸ’«

this page is from perl v5.36.0, dated 2023-08-02, and it's filed under CSS::D...::Media(3pm). Consider yourself fully caught up. Go forth and style responsibly, bestie β€” you ate, periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from