Skip to content

Commit 545f86a

Browse files
committed
🛀 update Sizzle to latest and hardcode it as the sole selector engine
1 parent 6c62e68 commit 545f86a

File tree

7 files changed

+2493
-7
lines changed

7 files changed

+2493
-7
lines changed

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module PrototypeHelper
1717
TMP_DIR = File.join(TEST_UNIT_DIR, 'tmp')
1818
VERSION = YAML.load(IO.read(File.join(SRC_DIR, 'constants.yml')))['PROTOTYPE_VERSION']
1919

20-
DEFAULT_SELECTOR_ENGINE = 'sizzle'
20+
# DEFAULT_SELECTOR_ENGINE = 'sizzle'
2121

2222
host = RbConfig::CONFIG['host']
2323
IS_WINDOWS = host.include?('mswin') || host.include?('mingw32')
@@ -245,7 +245,7 @@ task :dist do
245245
PrototypeHelper.sprocketize(
246246
:path => 'src',
247247
:source => 'prototype.js',
248-
:selector_engine => ENV['SELECTOR_ENGINE'] || PrototypeHelper::DEFAULT_SELECTOR_ENGINE
248+
# :selector_engine => ENV['SELECTOR_ENGINE'] || PrototypeHelper::DEFAULT_SELECTOR_ENGINE
249249
)
250250
end
251251

src/prototype/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//= require "dom/dom"
33
//= require "dom/layout"
44
//= require "dom/selector"
5-
//= require <selector_engine>
5+
//= require "dom/selector_engine"
66
//= require "dom/form"
77
//= require "dom/event"
88

vendor/sizzle/selector_engine.js renamed to src/prototype/dom/selector_engine.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
Prototype._original_property = window.Sizzle;
23

34
;(function () {
@@ -15,7 +16,7 @@ Prototype._original_property = window.Sizzle;
1516
}
1617
})();
1718

18-
//= require "repository/dist/sizzle"
19+
//= require "../../../vendor/sizzle/sizzle"
1920

2021
;(function() {
2122
if (typeof Sizzle !== 'undefined') {
@@ -46,7 +47,7 @@ Prototype._original_property = window.Sizzle;
4647
}
4748

4849
function match(element, selector) {
49-
return engine.matches(selector, [element]).length == 1;
50+
return engine.matches(selector, [element]).length === 1;
5051
}
5152

5253
Prototype.Selector.engine = engine;

test/unit/tests/selector.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ suite('Selector', function () {
7474
assert.enumEqual([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]');
7575
});
7676

77+
// Unescaped # errors out with "Syntax error, unrecognized expression"
78+
// https://github.com/jquery/jquery/issues/2824
7779
test('tag + attr equality (a[href="#"])', function () {
78-
assert.enumEqual($('link_1', 'link_2', 'link_3'), $$('#fixtures a[href="#"]'));
79-
assert.enumEqual($('link_1', 'link_2', 'link_3'), $$('#fixtures a[href=#]'));
80+
assert.enumEqual($('link_1', 'link_2', 'link_3'), $$('#fixtures a[href="\\#"]'));
81+
assert.enumEqual($('link_1', 'link_2', 'link_3'), $$('#fixtures a[href=\\#]'));
8082
});
8183

84+
8285
test('tag + attr whitespace-tokenized (a[class~="internal"])', function () {
8386
assert.enumEqual($('link_1', 'link_2'), $$('a[class~="internal"]'), "a[class~=\"internal\"]");
8487
assert.enumEqual($('link_1', 'link_2'), $$('a[class~=internal]'), "a[class~=internal]");

0 commit comments

Comments
 (0)