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

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

πŸ’– CSS::DOM::Rule::Import β€” bestie edition πŸ’–

okay so this is CSS::DOM::Rule::Import, a Perl module from the User Contributed Perl Documentation shelf, and it's literally the CSS @import rule class for CSS::DOM. yeah. that's the whole vibe. let's get into it 🫢


✨ VERSION ✨

Version 0.17 β€” she's grown, she's thriving, she's stable πŸ’…


🌸 SYNOPSIS 🌸

here's the whole thing in action, no cap:

use CSS::DOM;
my $import_rule = CSS::DOM->parse(
    '@import "print.css" print;',
    url_fetcher => sub {
        # ... code to get the url in $_[0] ...
    }
)->cssRules->[0];

$import_rule->href;  # 'print.css'
$import_rule->media; # a CSS::DOM::MediaList (array ref)
$import_rule->styleSheet; # a CSS::DOM object

see how it just… works? iconic. the url_fetcher sub is where you go get the URL that lands in $_[0], that part's on you bestie πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module implements the CSS @import rules for CSS::DOM. It inherits from CSS::DOM::Rule, and it implements the CSSImportRule DOM interface. So basically: it's the glow-up of an @import statement, wearing the DOM interface as its little outfit ✨


πŸ‘‘ METHODS πŸ‘‘

πŸ’œ href

Returns the @import rule's URL. that's it. that's the method. short queen behavior πŸŽ€

🌈 media

Returns the MediaList associated with the @import rule β€” or a plain list if you're in list context, because she contains multitudes. This defaults to an empty list. If you wanna set it, you can pass a comma-delimited string to the MediaList's mediaText method. periodt.

🧚 styleSheet

This returns the style sheet object, if available. Otherwise it returns an empty list β€” which happens if url_fetcher is not provided, or if it returns undef. so like, no fetcher, no sheet, no problem, just an empty list and a little bit of sadness 😭


πŸ“ SEE ALSO πŸ“

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

πŸ’€ reminder bestie: if url_fetcher is missing (or hands back undef), styleSheet is gonna give you an empty list. that's not a bug, that's the documented behavior. lowkey important, highkey fine.

and that's the page!! written up in the Perl v5.36.0 docs dated 2023-08-02, filed under CSS::D...Import(3pm). mwah, go import something cute πŸ’…βœ¨

πŸ“¦ where this page comes from