POE::XUL::TextNode - XUL TextNode


POE-XUL documentation Contained in the POE-XUL distribution.

Index


Code Index:

NAME

Top

POE::XUL::TextNode - XUL TextNode

SYNOPSIS

Top

    use POE::XUL::Node;
    use POE::XUL::TextNode;

    # Explicitly create a TextNode
    my $node = POE::XUL::TextNode->new( "Just some text" );
    print $node->nodeValue;

    # Implicitly create a TextNode
    my $desc = Description( "This is my description node" );
    print $desc->firstChild->nodeValue;

DESCRIPTION

Top

POE::XUL::TextNode instances is are objects for holding and manipulating plain text. This permits mixed-mode nodes, that is nodes that contain both text and other nodes.

METHODS

Top

new

    my $textnode = POE::XUL::TextNode->new( "Some Text" );

nodeValue

    my $text = $textnode->nodeValue;

Returns the text of a TextNode. You may also set the text of the node.

    $textnode->nodeValue( $other_text );

Of course this isn't possible in the browser's DOM; it is simulated by replacing the previous node with a new one.

value

Synonym for nodeValue.

as_xml

    my $escaped_text = $textnode->as_xml;

children

Returns an empty array.

dispose

Does nothing.

AUTHOR

Top

Philip Gwyn <gwyn-at-cpan.org>

CREDITS

Top

Based on XUL::Node by Ran Eilam.

COPYRIGHT AND LICENSE

Top

SEE ALSO

Top

perl(1), POE::XUL, POE::XUL::Node, POE::XUL::CDATA.


POE-XUL documentation Contained in the POE-XUL distribution.

package POE::XUL::TextNode;
# $Id: TextNode.pm 1566 2010-11-03 03:13:32Z fil $
# Copyright Philip Gwyn 2007-2010.  All rights reserved.

use strict;
use warnings;
use Carp;
use HTML::Entities qw( encode_entities_numeric );

our $VERSION = '0.0600';


################################################################
sub new
{
    my( $package, $text ) = @_;
    return bless { attributes => { value=>$text } }, $package;
}

################################################################
sub is_window { 0 }


################################################################
sub nodeValue
{
    my( $self, $value ) = @_;
    
    if( 2==@_ ) {
        if( $POE::XUL::Node::CM ) {
            $POE::XUL::Node::CM->after_set_attribute( $self, 
                                                      'textnode',
                                                        $value );
        }
        $_[0]->{attributes}{value} = $value;
    }
    return $_[0]->{attributes}{value};
}
*value = \&nodeValue;

################################################################
sub as_xml
{
    encode_entities_numeric( $_[0]->{attributes}{value}, 
                             "\x00-\x1f<>&\'\x80-\xff" );
}

################################################################
sub children
{
    return;
}

################################################################
sub dispose
{
    return;
}

################################################################
sub DESTROY
{
    my( $self ) = @_;
    $POE::XUL::Node::CM->after_destroy( $self )
                    if $POE::XUL::Node::CM;
}

1;

__DATA__