Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS case insensitive attribute selector operator #2036

Open
Juice10 opened this issue May 27, 2020 · 2 comments
Open

CSS case insensitive attribute selector operator #2036

Juice10 opened this issue May 27, 2020 · 2 comments

Comments

@Juice10
Copy link

Juice10 commented May 27, 2020

Describe the bug

When using .css(input[type=checkbox i] Nokogiri kicks up an error: Nokogiri::CSS::SyntaxError (unexpected ' ' after '[:equal, "checkbox"]')

To Reproduce

#! /usr/bin/env ruby

require 'nokogiri'
require 'minitest/autorun'

class Test < MiniTest::Spec
  describe "Node#css" do
    it "should find a div using chained classes" do
      html = <<~HEREDOC
        <html>
          <body>
            <input type="CHECKBOX" />
      HEREDOC
      
      doc = Nokogiri::HTML::Document.parse(html)
      
      assert_equal 1, doc.css("input[type=checkbox i]").length
    end
  end
end

Expected behavior

The i modifier should make the attribute selector case-insensitive.

Environment

# Nokogiri (1.10.9)
    ---
    warnings: []
    nokogiri: 1.10.9
    ruby:
      version: 2.7.1
      platform: x86_64-darwin19
      description: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
      engine: ruby
    libxml:
      binding: extension
      source: system
      compiled: 2.9.4
      loaded: 2.9.4

Additional context

More information on attribute selector operators: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

@flavorjones
Copy link
Member

Hi, @Juice10! Thanks for opening this issue.

Unfortunately, it looks like we have never tried to add support for the case-sensitivity attribute selectors. This is relatively new, in Selectors Level 4 which is still in draft (although we're probably all familiar with how that works).

I'm unlikely to work on adding this support while I'm still trying to get v1.11.0 out the door, but I'll prioritize it after that. In the meantime, if you have time to work on this, I'd be super happy to help you craft a PR!

@flavorjones
Copy link
Member

It seems likely we'll be able to deliver this as part of the CSS selector rewrite (see #2560) which is scheduled to land in v2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants