jquery-rails 4.0.3 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cbce5dcfc21bb4fb2839710ac0e05159888322b0
4
- data.tar.gz: fc45d73e7fcbb5a41d0dcd63c388f77ac4c4e718
2
+ SHA256:
3
+ metadata.gz: ab13d042048cc568bf3c47322a53992a86c26e153beb4298008a61b1bf26b772
4
+ data.tar.gz: 2e1b815b3f09adc49539628fe5331222f71dcbb7101a3a3e4591fca79241087b
5
5
  SHA512:
6
- metadata.gz: c0a6d1bd050ea314a9ba5fa5ca62064b915ea5d9587b2387c054e0ba180fb1c9d5b2b5ab4364655eda865a6cafd3d7a0ff2e277dece297a7afd435b68be6a612
7
- data.tar.gz: f04822fcbc830e85d4187290efce0347067ab70474e9c7aa4c56d93fdf8c7390eae158f8970b7ab853fc05325375c7f4d2934a029f74f2df210fcbef37fe29e2
6
+ metadata.gz: 51c887d6c520f1366d0982280c6516825b1cb9561a8a310661e984e1d6d47806edeff197d085e5edf704b9754e8d57c9f8fb449446032f9e6e429e9c40986aa4
7
+ data.tar.gz: 9bf9832f9a1ba125d7a36aef545c84b692284a586c7aa50c64ea4dc75f25dce69d762749fcb7bbba1612cf9c1a5483d317ab4a36d9a59717007089ee1c7dac18
data/.travis.yml ADDED
@@ -0,0 +1,32 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.10
8
+ - 2.2.9
9
+ - 2.3.6
10
+ - 2.4.10
11
+ - 2.5.8
12
+ - 2.6.6
13
+ - 2.7.1
14
+ - jruby
15
+ - ruby-head
16
+ matrix:
17
+ fast_finish: true
18
+ allow_failures:
19
+ - rvm: jruby
20
+ - rvm: ruby-head
21
+ notifications:
22
+ email: false
23
+ irc:
24
+ on_success: change
25
+ on_failure: always
26
+ channels:
27
+ - "irc.freenode.org#rails-contrib"
28
+ campfire:
29
+ on_success: change
30
+ on_failure: always
31
+ rooms:
32
+ - secure: "p58t43P+64c1g0Av88DNM9XxMnmXM/PzRFU4yeo53i7lDY77PqKOVY+swc8eibn6cMgfyw2vqI7UFri4WLxwdN5jN5QaByHtXT2STFaJV4ORyyOBqQLuJTFWzMn8+Zil3rW/0Xv6tHoeAjsToZyYFefyjM3qemAmUqI8jLqU1sM="
data/CHANGELOG.md CHANGED
@@ -1,3 +1,86 @@
1
+ ## unreleased
2
+
3
+ ## 4.6.0
4
+
5
+ - update jquery to 3.7.0
6
+
7
+ ## 4.5.1
8
+
9
+ - update jquery to 3.6.1
10
+ - update jquery-ujs to 1.2.3
11
+
12
+ ## 4.5.0
13
+
14
+ - update jquery to 3.6.0
15
+
16
+ ## 4.4.0
17
+
18
+ - update jquery to 3.5.1 (note: [3.5.0 contains important security updates](https://github.com/advisories/GHSA-jpcq-cgw6-v4j6))
19
+ - unescape dollar signs and backticks in `assert_select_jquery` to match
20
+ Rails updated behavior.
21
+
22
+ ## 4.3.5
23
+
24
+ - update jquery to 3.4.1
25
+
26
+ ## 4.3.4
27
+
28
+ - update jquery to 3.4.0
29
+
30
+ ## 4.3.3
31
+
32
+ - update jquery to 3.3.1
33
+
34
+ ## 4.3.2
35
+
36
+ - update jquery to 3.3.0
37
+ - Add possibility to test HTML: all, attribute prefix, attribute contains,
38
+ attribute ends with, child, and class selectors
39
+ - Fix matching multiple calls for the same selector/function exception
40
+
41
+ ## 4.3.1
42
+
43
+ - update jquery to 3.2.1
44
+
45
+ ## 4.3.0
46
+
47
+ - update jquery to 3.2.0
48
+ - Add possibility to test HTML attribute selectors
49
+
50
+ ## 4.2.2
51
+
52
+ - update jquery to 3.1.1
53
+
54
+ ## 4.2.1
55
+
56
+ - update jquery to 3.1.0
57
+
58
+ ## 4.2.0
59
+
60
+ - Support jQuery 3.x
61
+ - Update jquery-ujs to 1.2.2
62
+ - Update jQuery to 1.12.4 and 2.2.4
63
+
64
+ ## 4.1.1
65
+
66
+ - Update jQuery to 1.12.1 and 2.2.1
67
+ - Update jquery-ujs to 1.2.1
68
+
69
+ ## 4.1.0
70
+
71
+ - Update jQuery to 1.12.0 and 2.2.0
72
+ - Update jquery-ujs to 1.2.0
73
+
74
+ ## 4.0.5
75
+
76
+ - Specify that Ruby version 1.9.3+ is required
77
+ - Test on Ruby 2.2
78
+ - Update jquery-ujs from 1.0.4 to 1.1.0
79
+
80
+ ## 4.0.4
81
+
82
+ - Fix CSP bypass vulnerability. CVE-2015-1840
83
+
1
84
  ## 4.0.1
2
85
 
3
86
  - Fix RubyGems permission problem.
@@ -8,6 +91,10 @@
8
91
  - Updated to jquery-ujs 1.0.2
9
92
  - Support jQuery 1.x and 2.x
10
93
 
94
+ ## 3.1.3 (16 June 2015)
95
+
96
+ - Fix CSP bypass vulnerability. CVE-2015-1840
97
+
11
98
  ## 3.1.2 (1 September 2014)
12
99
 
13
100
  - Updated to jquery-ujs 1.0.1
data/CONTRIBUTING.md CHANGED
@@ -1,17 +1,53 @@
1
- Thanks for taking the time to contribute to jquery-rails! Please
2
- take a moment to read the following brief guidelines to help streamline
3
- the merging process.
1
+ Contributing to jquery-rails
2
+ =====================
4
3
 
5
- ## Updating jQuery
4
+ [![Build Status](https://travis-ci.org/rails/jquery-rails.svg?branch=master)](https://travis-ci.org/rails/jquery-rails)
5
+
6
+ jquery-rails is work of [many contributors](https://github.com/rails/jquery-rails/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/rails/jquery-rails/pulls), [propose features and discuss issues](https://github.com/rails/jquery-rails/issues).
7
+
8
+ #### Updating jQuery
6
9
 
7
10
  If the jquery or jquery-ui scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jquery or jquery-ui scripts.
8
11
 
9
- ## Changes to jquery_ujs.js
12
+ #### Changes to jquery_ujs.js
10
13
 
11
14
  **If it's an issue pertaining to the jquery-ujs javascript, please
12
15
  report it to the [rails/jquery-ujs project](https://github.com/rails/jquery-ujs/issues).**
13
16
 
14
- ## Tests
17
+ #### Fork the Project
18
+
19
+ Fork the [project on Github](https://github.com/rails/jquery-rails) and check out your copy.
20
+
21
+ ```
22
+ git clone https://github.com/contributor/jquery-rails.git
23
+ cd jquery-rails
24
+ git remote add upstream https://github.com/rails/jquery-rails.git
25
+ ```
26
+
27
+ #### Create a Topic Branch
28
+
29
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
30
+
31
+ ```
32
+ git checkout master
33
+ git pull upstream master
34
+ git checkout -b my-feature-branch
35
+ ```
36
+
37
+ #### Bundle Install and Test
38
+
39
+ Ensure that you can build the project and run tests.
40
+
41
+ ```
42
+ bundle install
43
+ bundle exec rake test
44
+ ```
45
+
46
+ #### Write Tests
47
+
48
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [test](test).
49
+
50
+ #### Testing
15
51
 
16
52
  This is a gem that simply includes jQuery and jQuery UJS into the Rails
17
53
  asset pipeline. The asset pipeline functionality is well tested within the
@@ -29,8 +65,68 @@ If you're making changes to the actual gem, run the tests as follows:
29
65
  2. Install the gems: `bundle install`
30
66
 
31
67
  3. Change the jquery-rails gem in the Gemfile to use your local
32
- version of the gem with your updates: `gem 'rspec-rails', :path => '../path/to/jquery-rails'`
68
+ version of the gem with your updates: `gem 'jquery-rails', :path => '../path/to/jquery-rails'`
33
69
 
34
70
  4. Update your bundled jquery-rails gem: `bundle update jquery-rails`
35
71
 
36
72
  5. Run the tests: `bundle exec rspec spec/`
73
+
74
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
75
+
76
+ #### Write Code
77
+
78
+ Implement your feature or bug fix.
79
+
80
+ Make sure that `bundle exec rake test` completes without errors.
81
+
82
+ #### Write Documentation
83
+
84
+ Document any external behavior in the [README](README.md).
85
+
86
+ #### Commit Changes
87
+
88
+ Make sure git knows your name and email address:
89
+
90
+ ```
91
+ git config --global user.name "Your Name"
92
+ git config --global user.email "contributor@example.com"
93
+ ```
94
+
95
+ Writing good commit logs is important. A commit log should describe what changed and why.
96
+
97
+ ```
98
+ git add ...
99
+ git commit
100
+ ```
101
+
102
+ #### Push
103
+
104
+ ```
105
+ git push origin my-feature-branch
106
+ ```
107
+
108
+ #### Make a Pull Request
109
+
110
+ Go to https://github.com/contributor/jquery-rails and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
111
+
112
+ #### Rebase
113
+
114
+ If you've been working on a change for a while, rebase with upstream/master.
115
+
116
+ ```
117
+ git fetch upstream
118
+ git rebase upstream/master
119
+ git push origin my-feature-branch -f
120
+ ```
121
+
122
+ #### Check on Your Pull Request
123
+
124
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
125
+
126
+ #### Be Patient
127
+
128
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
129
+
130
+ #### Thank You
131
+
132
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/Gemfile CHANGED
@@ -1,4 +1,22 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "mime-types", "< 3", group: :test
4
+
5
+ if RUBY_VERSION >= '2.2.2'
6
+ gem 'rails'
7
+ gem 'rack'
8
+ gem 'json', '>= 2'
9
+ else
10
+ gem 'rails', '~> 4.2.0'
11
+ gem 'rack', '~>1.6'
12
+ gem 'json', '~> 1.8.0'
13
+ end
14
+
15
+ if RUBY_VERSION >= '2.1'
16
+ gem 'nokogiri'
17
+ else
18
+ gem 'nokogiri', '~> 1.6.0'
19
+ end
20
+
3
21
  # Specify your gem's dependencies in jquery-rails.gemspec
4
22
  gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2010 Andre Arko
3
+ Copyright (c) 2010-2016 Andre Arko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -4,7 +4,7 @@ jQuery! For Rails! So great.
4
4
 
5
5
  This gem provides:
6
6
 
7
- * jQuery 1.11.1 and jQuery 2.1.1
7
+ * jQuery 1, 2 and 3
8
8
  * the jQuery UJS adapter
9
9
  * assert_select_jquery to test jQuery responses in Ruby tests
10
10
 
@@ -24,6 +24,12 @@ versions of jQuery.
24
24
 
25
25
  ## Installation
26
26
 
27
+ Add
28
+ ```
29
+ gem 'jquery-rails'
30
+ ```
31
+ to your Gemfile.
32
+
27
33
  The jquery and jquery-ujs files will be added to the asset pipeline and available for you to use. If they're not already in `app/assets/javascripts/application.js` by default, add these lines:
28
34
 
29
35
  ```js
@@ -31,6 +37,12 @@ The jquery and jquery-ujs files will be added to the asset pipeline and availabl
31
37
  //= require jquery_ujs
32
38
  ```
33
39
 
40
+ If you are running Rails 5.1 and up, and if you have included `//= require rails-ujs`, then `jquery_ujs` is not needed anymore. You can just add:
41
+
42
+ ```js
43
+ //= require jquery
44
+ ```
45
+
34
46
  If you want to use jQuery 2, you can require `jquery2` instead:
35
47
 
36
48
  ```js
@@ -38,21 +50,32 @@ If you want to use jQuery 2, you can require `jquery2` instead:
38
50
  //= require jquery_ujs
39
51
  ```
40
52
 
53
+ And if you want to use jQuery 3, you can require `jquery3`:
54
+
55
+ ```js
56
+ //= require jquery3
57
+ //= require jquery_ujs
58
+ ```
59
+
41
60
  For jQuery UI, we recommend the [jquery-ui-rails](https://github.com/joliss/jquery-ui-rails) gem, as it includes the jquery-ui css and allows easier customization.
42
61
 
43
62
  *As of v3.0, jquery-rails no longer includes jQuery UI. Use the
44
63
  jquery-ui-rails gem above.*
45
64
 
46
- ## Contributing
65
+ ## Contributing to jquery-rails
47
66
 
48
- Feel free to open an issue ticket if you find something that could be improved. A couple notes:
67
+ jquery-rails is work of many contributors. You're encouraged to submit pull requests, propose
68
+ features and discuss issues.
49
69
 
50
70
  * If it's an issue pertaining to the jquery-ujs javascript, please report it to the [jquery-ujs project](https://github.com/rails/jquery-ujs).
51
71
 
52
72
  * If the jQuery scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jQuery scripts.
53
73
 
54
- ## Acknowledgements
74
+ See [CONTRIBUTING](CONTRIBUTING.md).
55
75
 
56
- Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/organizations/rails/teams/617) for making jquery-rails an official part of Rails 3.1.
76
+ ## License
77
+ jquery-rails is released under the [MIT License](MIT-LICENSE).
78
+
79
+ ## Acknowledgements
57
80
 
58
- Copyright [André Arko](http://arko.net), released under the MIT License.
81
+ Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/orgs/rails/people) for making jquery-rails an official part of Rails 3.1.
data/Rakefile CHANGED
@@ -1,6 +1,16 @@
1
1
  require 'bundler'
2
+ require 'rake/testtask'
2
3
  Bundler::GemHelper.install_tasks
3
4
 
5
+ task default: :test
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'lib'
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.warning = true
11
+ t.verbose = true
12
+ end
13
+
4
14
  # Check if versions are correct between VERSION constants and .js files
5
15
  #
6
16
  task :release => [:guard_version]
@@ -9,7 +19,7 @@ task :guard_version do
9
19
  def check_version(file, pattern, constant)
10
20
  body = File.read("vendor/assets/javascripts/#{file}")
11
21
  match = body.match(pattern) or abort "Version check failed: no pattern matched in #{file}"
12
- file_version = body.match(pattern)[1]
22
+ file_version = match[1]
13
23
  constant_version = Jquery::Rails.const_get(constant)
14
24
 
15
25
  unless constant_version == file_version
@@ -19,6 +29,7 @@ task :guard_version do
19
29
 
20
30
  check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
21
31
  check_version('jquery2.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_2_VERSION')
32
+ check_version('jquery3.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_3_VERSION')
22
33
  end
23
34
 
24
35
  desc "Update jQuery versions"
@@ -27,15 +38,16 @@ task :update_jquery do
27
38
  suffix = "-#{version}"
28
39
 
29
40
  puts "Downloading #{filename}.js"
30
- puts `curl -o vendor/assets/javascripts/#{filename}.js http://code.jquery.com/jquery#{suffix}.js`
41
+ puts `curl -o vendor/assets/javascripts/#{filename}.js https://code.jquery.com/jquery#{suffix}.js`
31
42
  puts "Downloading #{filename}.min.js"
32
- puts `curl -o vendor/assets/javascripts/#{filename}.min.js http://code.jquery.com/jquery#{suffix}.min.js`
43
+ puts `curl -o vendor/assets/javascripts/#{filename}.min.js https://code.jquery.com/jquery#{suffix}.min.js`
33
44
  puts "Downloading #{filename}.min.map"
34
- puts `curl -o vendor/assets/javascripts/#{filename}.min.map http://code.jquery.com/jquery#{suffix}.min.map`
45
+ puts `curl -o vendor/assets/javascripts/#{filename}.min.map https://code.jquery.com/jquery#{suffix}.min.map`
35
46
  end
36
47
 
37
48
  download_jquery('jquery', Jquery::Rails::JQUERY_VERSION)
38
49
  download_jquery('jquery2', Jquery::Rails::JQUERY_2_VERSION)
50
+ download_jquery('jquery3', Jquery::Rails::JQUERY_3_VERSION)
39
51
  puts "\e[32mDone!\e[0m"
40
52
  end
41
53
 
data/VERSIONS.md CHANGED
@@ -2,10 +2,28 @@
2
2
 
3
3
  | Gem | jQuery | jQuery UJS | jQuery UI |
4
4
  |--------|--------|------------| ----------|
5
+ | 4.6.0 | 1.12.4 & 2.2.4 & 3.7.0 | 1.2.3 | - |
6
+ | 4.5.1 | 1.12.4 & 2.2.4 & 3.6.1 | 1.2.3 | - |
7
+ | 4.5.0 | 1.12.4 & 2.2.4 & 3.6.0 | 1.2.2 | - |
8
+ | 4.4.0 | 1.12.4 & 2.2.4 & 3.5.1 | 1.2.2 | - |
9
+ | 4.3.5 | 1.12.4 & 2.2.4 & 3.4.1 | 1.2.2 | - |
10
+ | 4.3.4 | 1.12.4 & 2.2.4 & 3.4.0 | 1.2.2 | - |
11
+ | 4.3.3 | 1.12.4 & 2.2.4 & 3.3.1 | 1.2.2 | - |
12
+ | 4.3.2 | 1.12.4 & 2.2.4 & 3.3.0 | 1.2.2 | - |
13
+ | 4.3.1 | 1.12.4 & 2.2.4 & 3.2.1 | 1.2.2 | - |
14
+ | 4.3.0 | 1.12.4 & 2.2.4 & 3.2.0 | 1.2.2 | - |
15
+ | 4.2.2 | 1.12.4 & 2.2.4 & 3.1.1 | 1.2.2 | - |
16
+ | 4.2.1 | 1.12.4 & 2.2.4 & 3.1.0 | 1.2.2 | - |
17
+ | 4.2.0 | 1.12.4 & 2.2.4 & 3.0.0 | 1.2.2 | - |
18
+ | 4.1.1 | 1.12.1 & 2.2.1 | 1.2.1 | - |
19
+ | 4.1.0 | 1.12.0 & 2.2.0 | 1.2.0 | - |
20
+ | 4.0.5 | 1.11.3 & 2.1.4 | 1.1.0 | - |
21
+ | 4.0.4 | 1.11.2 & 2.1.3 | 1.0.4 | - |
5
22
  | 4.0.3 | 1.11.2 & 2.1.3 | 1.0.3 | - |
6
23
  | 4.0.2 | - | - | - |
7
24
  | 4.0.1 | - | - | - |
8
25
  | 4.0.0 | 1.11.1 & 2.1.1 | 1.0.2 | - |
26
+ | 3.1.3 | 1.11.1 | 1.0.4 | - |
9
27
  | 3.1.2 | 1.11.1 | 1.0.1 | - |
10
28
  | 3.1.1 | 1.11.1 | 1.0.0 | - |
11
29
  | 3.1.0 | 1.11.0 | - | - |
data/jquery-rails.gemspec CHANGED
@@ -7,18 +7,18 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["André Arko"]
9
9
  s.email = ["andre@arko.net"]
10
- s.homepage = "http://rubygems.org/gems/jquery-rails"
10
+ s.homepage = "https://github.com/rails/jquery-rails"
11
11
  s.summary = "Use jQuery with Rails 4+"
12
12
  s.description = "This gem provides jQuery and the jQuery-ujs driver for your Rails 4+ application."
13
13
  s.license = "MIT"
14
14
 
15
+ s.required_ruby_version = ">= 1.9.3"
15
16
  s.required_rubygems_version = ">= 1.3.6"
16
- s.rubyforge_project = "jquery-rails"
17
17
 
18
18
  s.add_dependency "railties", ">= 4.2.0"
19
19
  s.add_dependency "thor", ">= 0.14", "< 2.0"
20
20
 
21
- s.add_dependency "rails-dom-testing", "~> 1.0"
21
+ s.add_dependency "rails-dom-testing", ">= 1", "< 3"
22
22
 
23
23
  s.files = `git ls-files`.split("\n")
24
24
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
@@ -41,34 +41,69 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
41
41
  # assert_select :html, '#cart' do
42
42
  # assert_select '#current_item'
43
43
  # end
44
+ #
45
+ # # asserts that #product append to a #product_list
46
+ # assert_select_jquery :appendTo, '#product_list' do
47
+ # assert_select '.product'
48
+ # end
44
49
 
45
- PATTERN_HTML = "\"((\\\\\"|[^\"])*)\""
50
+ PATTERN_HTML = "['\"]((\\\\\"|\\\\'|[^\"'])*)['\"]"
46
51
  PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
52
+ SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\)[;]?"
47
53
 
48
54
  def assert_select_jquery(*args, &block)
49
55
  jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
50
56
  jquery_opt = args.first.is_a?(Symbol) ? args.shift : nil
51
- id = args.first.is_a?(String) ? args.shift : nil
52
-
53
- pattern = "\\s*\\.#{jquery_method || '\\w+'}\\("
54
- pattern = "#{pattern}['\"]#{jquery_opt}['\"],?\\s*" if jquery_opt
55
- pattern = "#{pattern}#{PATTERN_HTML}"
56
- pattern = "(?:jQuery|\\$)\\(['\"]#{id}['\"]\\)#{pattern}" if id
57
-
58
- fragments = Nokogiri::HTML::Document.new
59
- response.body.scan(Regexp.new(pattern)).each do |match|
60
- doc = Nokogiri::HTML::Document.parse(unescape_js(match.first))
61
- doc.root.children.each do |child|
62
- fragments << child if child.element?
57
+ id = args.first.is_a?(String) ? escape_id(args.shift) : nil
58
+
59
+ target_pattern = "['\"]#{id || '.*'}['\"]"
60
+ method_pattern = "#{jquery_method || '\\w+'}"
61
+ argument_pattern = jquery_opt ? "['\"]#{jquery_opt}['\"].*" : PATTERN_HTML
62
+
63
+ # $("#id").show('blind', 1000);
64
+ # $("#id").html("<div>something</div>");
65
+ # $("#id").replaceWith("<div>something</div>");
66
+ target_as_receiver_pattern = SKELETAL_PATTERN % [target_pattern, method_pattern, argument_pattern]
67
+
68
+ # $("<div>something</div>").appendTo("#id");
69
+ # $("<div>something</div>").prependTo("#id");
70
+ target_as_argument_pattern = SKELETAL_PATTERN % [argument_pattern, method_pattern, target_pattern]
71
+
72
+ # $("#id").remove();
73
+ # $("#id").hide();
74
+ argumentless_pattern = SKELETAL_PATTERN % [target_pattern, method_pattern, '']
75
+
76
+ patterns = [target_as_receiver_pattern, target_as_argument_pattern]
77
+ patterns << argumentless_pattern unless jquery_opt
78
+
79
+ matched_pattern = nil
80
+ patterns.each do |pattern|
81
+ if response.body.match(Regexp.new(pattern))
82
+ matched_pattern = pattern
83
+ break
63
84
  end
64
85
  end
65
86
 
66
- unless fragments.children.any? { |child| child.element? }
87
+ unless matched_pattern
67
88
  opts = [jquery_method, jquery_opt, id].compact
68
89
  flunk "No JQuery call matches #{opts.inspect}"
69
90
  end
70
91
 
71
- if block
92
+ if block_given?
93
+ @selected ||= nil
94
+ fragments = Nokogiri::HTML::Document.new.fragment
95
+
96
+ if matched_pattern
97
+ response.body.scan(Regexp.new(matched_pattern)).each do |match|
98
+ flunk 'This function can\'t have HTML argument' if match.is_a?(String)
99
+
100
+ doc = Nokogiri::HTML::DocumentFragment.parse(unescape_js(match.first))
101
+ doc.children.each do |child|
102
+ fragments << child if child.element?
103
+ end
104
+ end
105
+ end
106
+
72
107
  begin
73
108
  in_scope, @selected = @selected, fragments
74
109
  yield
@@ -89,8 +124,28 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
89
124
  unescaped.gsub!('\n', "\n")
90
125
  unescaped.gsub!('\076', '>')
91
126
  unescaped.gsub!('\074', '<')
127
+ unescaped.gsub!(/\\\$/, '$')
128
+ unescaped.gsub!(/\\`/, '`')
92
129
  # js encodes non-ascii characters.
93
130
  unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
94
131
  unescaped
95
132
  end
133
+
134
+ def escape_id(selector)
135
+ return unless selector
136
+
137
+ id = selector.gsub('[', '\[')
138
+ id.gsub!(']', '\]')
139
+ id.gsub!('*', '\*')
140
+ id.gsub!('(', '\(')
141
+ id.gsub!(')', '\)')
142
+ id.gsub!('.', '\.')
143
+ id.gsub!('|', '\|')
144
+ id.gsub!('^', '\^')
145
+ id.gsub!('$', '\$')
146
+ id.gsub!('+', "\\\\+")
147
+ id.gsub!(',', '\,')
148
+
149
+ id
150
+ end
96
151
  end
@@ -1,8 +1,9 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "4.0.3"
4
- JQUERY_VERSION = "1.11.2"
5
- JQUERY_2_VERSION = "2.1.3"
6
- JQUERY_UJS_VERSION = "1.0.3"
3
+ VERSION = "4.6.0"
4
+ JQUERY_VERSION = "1.12.4"
5
+ JQUERY_2_VERSION = "2.2.4"
6
+ JQUERY_3_VERSION = "3.7.0"
7
+ JQUERY_UJS_VERSION = "1.2.3"
7
8
  end
8
9
  end