Sizzle css selector engine

Sizzle

This is an exact mirror of the Sizzle project, hosted at https://github.com/jquery/sizzle. SourceForge is not affiliated with Sizzle. For more information, see the SourceForge Open Source Mirror Directory.

A pure-JavaScript CSS selector engine designed to be easily dropped in to a host library. Browser support may differ between standalone Sizzle and libraries that include Sizzle. Please report issues on Sizzle’s issue tracker, rather than the trackers for disparate libraries. In order to build Sizzle, you should have Node.js/npm latest and git 1.7 or later (earlier versions might work OK, but are not tested). For Windows you have to download and install git and Node.js. Mac OS users should install Homebrew. Once Homebrew is installed, run brew install git to install git, and brew install node to install Node.js. Linux/BSD users should use their appropriate package managers to install git and Node.js, or build from source if you swing that way. Workarounds for Internet Explorer 6 are still in the code but the browser is no longer actively tested. Sizzle supports virtually all CSS 3 Selectors, including escaped selectors (.foo\+bar), Unicode selectors, and more.

Features

  • Provides a public API, which users interact with
  • Provides a extension API, for modifications to the selector engine
  • An internal API, used internally by Sizzle
  • Sizzle internally caches compiled selector functions and tokenization objects
  • Build, test, and compare the sizes of the built files
  • Run to re-lint, re-build, and re-test files as you change them
Читайте также:  Python как использовать dll

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A sizzlin’ hot selector engine.

License

jquery/sizzle

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A pure-JavaScript CSS selector engine designed to be easily dropped in to a host library.

In the spirit of open source software development, jQuery always encourages community code contribution. To help you get started and before you jump into writing code, be sure to read these important contribution guidelines thoroughly:

What you need to build Sizzle

In order to build Sizzle, you should have Node.js/npm latest and git 1.7 or later (earlier versions might work OK, but are not tested).

For Windows you have to download and install git and Node.js.

Mac OS users should install Homebrew. Once Homebrew is installed, run brew install git to install git, and brew install node to install Node.js.

Linux/BSD users should use their appropriate package managers to install git and Node.js, or build from source if you swing that way. Easy-peasy.

Clone a copy of the main Sizzle git repo by running:

git clone git@github.com:jquery/sizzle.git

In the sizzle/dist folder you will find build version of sizzle along with the minified copy and associated map file.

  • Run npm install , it’s also preferable (but not necessarily) to globally install grunt-cli package – npm install -g grunt-cli
  • Open test/index.html in the browser. Or run npm test / grunt test on the command line, if environment variables BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY are set up, it will attempt to use Browserstack service (you will need to install java on your machine so browserstack could connect to your local server), otherwise PhantomJS will be used.
  • The actual unit tests are in the test/unit directory.
  • npm run build or grunt will lint, build, test, and compare the sizes of the built files.
  • npm start or grunt start can be run to re-lint, re-build, and re-test files as you change them.
  • grunt -help will show other available commands.

Источник

Sizzle

In the spirit of open source software development, jQuery always encourages community code contribution. To help you get started and before you jump into writing code, be sure to read these important contribution guidelines thoroughly:

What you need to build Sizzle

In order to build Sizzle, you should have Node.js/npm latest and git 1.7 or later (earlier versions might work OK, but are not tested).

For Windows you have to download and install git and Node.js.

Mac OS users should install Homebrew. Once Homebrew is installed, run brew install git to install git, and brew install node to install Node.js.

Linux/BSD users should use their appropriate package managers to install git and Node.js, or build from source if you swing that way. Easy-peasy.

How to build Sizzle

Clone a copy of the main Sizzle git repo by running:

git clone git://github.com/jquery/sizzle.git

In the sizzle/dist folder you will find build version of sizzle along with the minified copy and associated map file.

Testing

  • Run npm install , it’s also preferable (but not necessarily) to globally install grunt-cli package – npm install -g grunt-cli
  • Open test/index.html in the browser. Or run npm test / grunt test on the command line, if environment variables BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY are set up, it will attempt to use Browserstack service (you will need to install java on your machine so browserstack could connect to your local server), otherwise PhantomJS will be used.
  • The actual unit tests are in the test/unit directory.

Developing with grunt

  • npm run build or grunt will lint, build, test, and compare the sizes of the built files.
  • npm start or grunt start can be run to re-lint, re-build, and re-test files as you change them.
  • grunt -help will show other available commands.

Источник

Используем Sizzle отдельно от jQuery

Sizzle — кроссбраузерный движок селекторов, реализованный на JavaScript и используемый в популярной библиотеке jQuery.

В современных браузерах Sizzle использует стандартные DOM-методы querySelectorAll() и matchesSelector() , обеспечивая высокое быстродействие. В старых же браузерах, а также для реализации нестандартных селекторов, применяется чисто скриптовая реализация — более медленная, но обеспечивающая совместимость даже с IE6/7.

Приятная особенность Sizzle — его автономность: если широкие возможности jQuery для конкретной задачи или проекта не нужны, можно использовать Sizzle как самостоятельную библиотеку, заметно выиграв тем самым в скорости загрузки: в минимизированном виде и с Gzip-сжатием Sizzle имеет объём всего 6 КБ (!) — это более чем в 5 раз меньше размера jQuery в аналогичных условиях.

Использовать Sizzle — не сложнее, чем jQuery:

var elements = Sizzle(‘.example > LI’);

Результатом будет стандартный JavaScript-список (объект Array ) элементов, соответствующих заданному селектору.

Как и в jQuery, в качестве второго аргумента Sizzle можно передать контекст поиска элементов — элемент, потомками которого требуется ограничить выборку (контекстом по умолчанию является весь HTML-документ — объект document ):

var context = document.getElementById(‘some-container’);
var elements = Sizzle(‘.example > LI’, context);

В качестве третьего аргумента можно передать существующий Array -список элементов, куда будут автоматически добавлены найденные элементы:

var spans = Sizzle(‘SPAN’);
var elems = Sizzle(‘DIV’, document, spans);
// Теперь переменные spans и elems содержат один и тот же
// список (объект Array) одних и тех же элементов SPAN и DIV.

Кроме того, в Sizzle доступны ещё две полезные функции, по функциональности родственные методу jQuery.filter() :

Sizzle.matchesSelector(element, selector) Определяет, соответствует ли HTML-элемент селектору. Возвращает булево значение ( true или false ). Sizzle.matches(selector, elements) Возвращает JavaScript-список ( Array ) элементов из списка, соответствующих селектору.

  • javascript,
  • jquery,
  • selectors,
  • sizzle,
  • snippets,
  • библиотеки,
  • избранное
  • Firefox 114
  • Firefox 113
  • Firefox 112
  • Firefox 111
  • Firefox 110
  • Как сделать кнопку ссылкой
  • Правильный DOCTYPE в HTML5
  • Сброс стилей в CSS
  • Отключение Caps Lock в Windows
  • Dell P2415Q. Авторский обзор 4K-монитора
  • Asus PQ22UC — 22″ OLED-монитор 4K
  • Dell UP3017Q — 30″ OLED-монитор 4K

Перепечатка любых материалов сайта в любом объёме запрещена

Источник

Оцените статью