The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Changes 09
MANIFEST 01
META.yml 11
Makefile.PL 11
README 017
lib/CSS/Tiny.pm 323
t/04_rt.t 037
7 files changed (This is a version diff) 589
@@ -1,5 +1,14 @@
 Revision history for Perl extension CSS-Tiny
 
+1.19 Fri  3 Sep 2010
+	- No functional changes
+	- Resolved RT #59037: CSS::Tiny reorders rules
+	- The use of Tie::IxHash to achieve ordering is now documented
+
+1.18 Fri  3 Sep 2010
+	- Resolved RT #60776: Parsing of multiple whitespace selectors
+	- Added test script specifically for RT regression tests
+
 1.17 Sun  4 Jul 2010
 	- Removed the use of Module::Install
 	- Allow read-string to be rerun again on an existing object,
@@ -7,6 +7,7 @@ README
 t/01_compile.t
 t/02_main.t
 t/03_inline_clone.t
+t/04_rt.t
 test.css
 xt/meta.t
 xt/pmv.t
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               CSS-Tiny
-version:            1.17
+version:            1.19
 abstract:           Read/Write .css files with as little code as possible
 author:
     - Adam Kennedy <adamk@cpan.org>
@@ -2,7 +2,7 @@ use strict;
 use vars qw{$VERSION};
 BEGIN {
 	require 5.004;
-	$VERSION = '1.17';
+	$VERSION = '1.19';
 }
 use ExtUtils::MakeMaker;
 
@@ -131,6 +131,23 @@ METHODS
     When an error occurs, you can retrieve the error message either from the
     $CSS::Tiny::errstr variable, or using the "errstr" method.
 
+CAVEATS
+  CSS Rule Order
+    While the order of rules in CSS is important, this is one of the
+    features that is sacrificed to keep things small and dependency-free. If
+    you need to preserve order yourself, we recommend that you upgrade to
+    the more powerful CSS module.
+
+    If this is not possible in your case, alternatively it can be done with
+    the help of another module such as Tie::IxHash:
+
+        my $css = CSS::Tiny->new;
+        tie %$css, 'Tie::IxHash';
+        $css->read('style.css');
+
+    Note: You will also need to remember to add the additional dependency to
+    your code or module in this case.
+
 SUPPORT
     Bugs should be reported via the CPAN bug tracker at
 
@@ -5,7 +5,7 @@ package CSS::Tiny;
 use strict;
 BEGIN {
 	require 5.004;
-	$CSS::Tiny::VERSION = '1.17';
+	$CSS::Tiny::VERSION = '1.19';
 	$CSS::Tiny::errstr  = '';
 }
 
@@ -47,13 +47,14 @@ sub read_string {
 		}
 
 		# Split in such a way as to support grouped styles
-		my $style = $1;
+		my $style      = $1;
+		my $properties = $2;
 		$style =~ s/\s{2,}/ /g;
 		my @styles = grep { s/\s+/ /g; 1; } grep { /\S/ } split /\s*,\s*/, $style;
 		foreach ( @styles ) { $self->{$_} ||= {} }
 
 		# Split into properties
-		foreach ( grep { /\S/ } split /\;/, $2 ) {
+		foreach ( grep { /\S/ } split /\;/, $properties ) {
 			unless ( /^\s*([\w._-]+)\s*:\s*(.*?)\s*$/ ) {
 				return $self->_error( "Invalid or unexpected property '$_' in style '$style'" );
 			}
@@ -284,6 +285,25 @@ so that it can be dropped directly onto an XHTML page.
 When an error occurs, you can retrieve the error message either from the
 C<$CSS::Tiny::errstr> variable, or using the C<errstr> method.
 
+=head1 CAVEATS
+
+=head2 CSS Rule Order
+
+While the order of rules in CSS is important, this is one of the features
+that is sacrificed to keep things small and dependency-free. If you need
+to preserve order yourself, we recommend that you upgrade to the more
+powerful L<CSS> module.
+
+If this is not possible in your case, alternatively it can be done with the
+help of another module such as L<Tie::IxHash>:
+
+    my $css = CSS::Tiny->new;
+    tie %$css, 'Tie::IxHash';
+    $css->read('style.css');
+
+Note: You will also need to remember to add the additional dependency to
+your code or module in this case.
+
 =head1 SUPPORT
 
 Bugs should be reported via the CPAN bug tracker at
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+# This test holds regression tests based on samples provided in various
+# rt.cpan.org bug reports.
+
+use strict;
+BEGIN {
+	$|  = 1;
+	$^W = 1;
+}
+
+use Test::More tests => 2;
+use CSS::Tiny;
+
+
+
+
+
+######################################################################
+# Bug #60776 for CSS-Tiny: Bug in selector parsing in CSS::Tiny
+
+# Test parsing of CSS selectors with multiple whitespace elements
+my $css = CSS::Tiny->read_string( <<'END_CSS' );
+.test  .bodySettings  {
+  font-size:  12px;
+}
+END_CSS
+isa_ok( $css, 'CSS::Tiny' );
+is_deeply(
+	[ %$css ],
+	[
+		'.test .bodySettings' => {
+			'font-size' => '12px',
+		},
+	],
+	'Bug 60776: Parsing with multiple whitespace',
+);