Skip to content

Loading…

Enable passing flag to CSS validator regarding vendor extensions #11

Open
wants to merge 1 commit into from

1 participant

@Capncavedan

Allows calling set_vendor_extension_warning! on a validator instance
to have the CSS evaluated with vendor extensions considered as
warnings rather than errors.

Like so:
set_vendor_extension_warning!('Warnings')

will cause CSS like -moz-border-radius: 3px to be a warning not an error

The default has not changed (which is to say, use the W3C's default).

You can set and change the level for a validator on the fly.

Valid arguments are 'Default', 'Warnings', or 'Errors'.
Other values are ignored.

Dan Buettner Enable passing flag to CSS validator regarding vendor extensions
Allows calling set_vendor_extension_warning! on a validator instance
to have the CSS evaluated with vendor extensions considered as
warnings rather than errors.

Like so:
set_vendor_extension_warning!('Warnings')

will cause CSS like -moz-border-radius: 3px to be a warning not an error

The default has not changed (which is to say, use the W3C's default).

You can set and change the level for a validator on the fly.

Valid arguments are 'Default', 'Warnings', or 'Errors'.
Other values are ignored.
5e18eab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2012
  1. Enable passing flag to CSS validator regarding vendor extensions

    Dan Buettner committed
    Allows calling set_vendor_extension_warning! on a validator instance
    to have the CSS evaluated with vendor extensions considered as
    warnings rather than errors.
    
    Like so:
    set_vendor_extension_warning!('Warnings')
    
    will cause CSS like -moz-border-radius: 3px to be a warning not an error
    
    The default has not changed (which is to say, use the W3C's default).
    
    You can set and change the level for a validator on the fly.
    
    Valid arguments are 'Default', 'Warnings', or 'Errors'.
    Other values are ignored.
Showing with 20 additions and 2 deletions.
  1. +7 −0 lib/w3c_validators/css_validator.rb
  2. +13 −2 test/test_css_validator.rb
View
7 lib/w3c_validators/css_validator.rb
@@ -51,6 +51,13 @@ def set_language!(lang = 'en')
@options[:lang] = lang
end
+ # whether to treat presence of CSS vendor extension as error or merely a warning
+ def set_vendor_extension_warning!(level = 'Default')
+ @options[:vextwarning] = nil if level.to_s.downcase == 'default'
+ @options[:vextwarning] = 'true' if level.to_s.downcase == 'warnings'
+ @options[:vextwarning] = 'false' if level.to_s.downcase == 'errors'
+ end
+
# Validate the CSS of an URI.
#
# Returns W3CValidators::Results.
View
15 test/test_css_validator.rb
@@ -15,6 +15,19 @@ def setup
sleep 1
end
+ def test_vendor_extensions_as_errors
+ @v.set_vendor_extension_warning!('Errors')
+ r = @v.validate_text('some-class { -moz-border-radius: 3px; }')
+ assert_errors r, 1
+ end
+
+ def test_vendor_extensions_as_warnings
+ @v.set_vendor_extension_warning!('Warnings')
+ r = @v.validate_text('some-class { -moz-border-radius: 3px; }')
+ assert_no_errors r
+ assert_warnings r, 1
+ end
+
def test_overriding_css_profile
@v.set_profile!(:svgbasic)
r = @v.validate_text(@invalid_fragment)
@@ -46,6 +59,4 @@ def test_validating_text_via_file
assert_errors r, 1
end
-
-
end
Something went wrong with that request. Please try again.