VERSION

Version 0.15

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

This module provides the \s-1CSS\s0 style declaration class for \s-1CSS::DOM\s0. (A style declaration is what comes between the braces in \*(C`p { margin: 0 }\*(C'.) It implements the CSSStyleDeclaration \s-1DOM\s0 interface.

CONSTRUCTORS

This parses the $string and returns a new style declaration object. This is useful if you have text from an \s-1HTML\s0 \*(C`style\*(C' attribute, for instance. For details on $property_parser, see CSS::DOM::PropertyParser. 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

Returns the body of this style declaration (without the braces). If you pass an argument, it will parsed and replace the existing \s-1CSS\s0 data. Returns the value of the named \s-1CSS\s0 property as a string. Returns an object representing the property's value. (See CSS::DOM::Value.) Removes the named property, returning its value.

getPropertyPriority

Returns the property's priority. This is usually the empty string or the word 'important'. Sets the \s-1CSS\s0 property named $name, giving it a value of $value and setting the priority to $priority.

length

Returns the number of properties Returns the name of the property at the given index.

parentRule

Returns the rule to which this declaration belongs. This method, not part of the \s-1DOM\s0, allows you to attach a call-back routine that is run whenever a change occurs to the style object (with the style object as 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 \s-1CSS\s0 property directly. Simply capitalise each letter in a \s-1CSS\s0 property name that follows a hyphen, then remove the hyphens, and you'll have the method name. E.g., call the \*(C`borderBottomWidth\*(C' method to get/set the border-bottom-width property. One exception to this is that \*(C`cssFloat\*(C' is the method used to access the 'float' property. (But you can also use the \*(C`float\*(C' method, though it's not part of the \s-1DOM\s0 standard.)

RELATED TO CSS::DOM::Style…

\s-1CSS::DOM\s0

CSS::DOM::Rule::Style

CSS::DOM::PropertyParser

HTML::DOM::Element