CSS::DOM::Style(3pm)

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

✨ NAME ✨

CSS::DOM::Style β€” CSS style declaration class for CSS::DOM πŸ’…

okay bestie, this is the CSS::DOM::Style(3pm) manual page, from the User Contributed Perl Documentation. It's the whole vibe for the style declaration class in CSS::DOM. No cap. 🫢

🌸 VERSION 🌸

Version 0.17 ✨ β€” that's the number, periodt.

πŸ¦‹ SYNOPSIS πŸ¦‹

use CSS::DOM::Style;

$style = CSS::DOM::Style::parse(' text-decoration: none ');

$style->cssText; # returns 'text-decoration: none'
$style->cssText('color: blue'); # replace contents

$style->getPropertyValue('color'); # 'blue'
$style->color;                     # same
$style->setProperty(color=>'green'); # change it
$style->color('green');              # same

πŸ’« DESCRIPTION πŸ’«

So this module is the CSS style declaration class for CSS::DOM. A style declaration is literally what lives between the braces in p { margin: 0 }. It implements the CSSStyleDeclaration DOM interface. Slay.

πŸŽ€ CONSTRUCTORS πŸŽ€

  • CSS::DOM::Style::parse( $string )
  • CSS::DOM::Style::parse( $string, property_parser => $parser )

These parse the $string and return a new style declaration object. This is useful if you have text from an HTML style attribute, for instance.

For details on $property_parser, see CSS::DOM::PropertyParser.

  • new CSS::DOM::Style $owner_rule
  • new CSS::DOM::Style owner => $owner_rule, property_parser => $p

You don't normally need to call this, but, in case you do, here it is. $owner_rule, which is optional, is expected to be a CSS::DOM::Rule object, or a subclass like CSS::DOM::Rule::Style.

πŸ‘‘ METHODS πŸ‘‘

  • cssText ( $new_value ) β€” returns the body of this style declaration, without the braces. If you pass an argument, it will be parsed and replace the existing CSS data.
  • getPropertyValue ( $name ) β€” returns the value of the named CSS property as a string.
  • getPropertyCSSValue ( $name ) β€” returns an object representing the property's value. (See CSS::DOM::Value.)
  • removeProperty ( $name ) β€” removes the named property, returning its value.
  • getPropertyPriority β€” returns the property's priority. This is usually the empty string or the word 'important'.
  • setProperty ( $name, $value, $priority ) β€” sets the CSS property named $name, giving it a value of $value and setting the priority to $priority.
  • length β€” returns the number of properties.
  • item ( $index ) β€” returns the name of the property at the given index.
  • parentRule β€” returns the rule to which this declaration belongs.
  • modification_handler ( $coderef ) β€” this method is not part of the DOM, and it lets you attach a call-back routine that runs whenever a change happens to the style object. The style object is its only argument. If you call it without an argument, it returns the current handler. With an argument, it returns the old value after setting it.
  • property_parser β€” this returns the parser that was passed to the constructor.

This module also has methods for accessing each CSS property directly. Simply capitalise each letter in a CSS property name that follows a hyphen, then remove the hyphens, and you'll have the method name. E.g., call the borderBottomWidth method to get/set the border-bottom-width property. One exception to this is that cssFloat is the method used to access the 'float' property. (But you can also use the float method, though it's not part of the DOM standard.)

🌈 SEE ALSO 🌈

  • CSS::DOM
  • CSS::DOM::Rule::Style
  • CSS::DOM::PropertyParser
  • HTML::DOM::Element

πŸ’– That's the whole page, bestie! This manual came from perl v5.36.0, dated 2023-08-02, and it's the CSS::DOM::Style(3pm) page. Mwah! πŸ’‹βœ¨

πŸ“¦ where this page comes from