* Element.match(@element, selector) -> boolean * - selector (String): A CSS selector. * * Checks if `element` matches the given CSS selector. * * ##### Examples * * language: html * * * *
(element, selector)
| 1551 | * // -> false |
| 1552 | **/ |
| 1553 | function match(element, selector) { |
| 1554 | element = $(element); |
| 1555 | |
| 1556 | // If selector is a string, we assume it's a CSS selector. |
| 1557 | if (Object.isString(selector)) |
| 1558 | return Prototype.Selector.match(element, selector); |
| 1559 | |
| 1560 | // Otherwise, we assume it's an object with its own `match` method. |
| 1561 | return selector.match(element); |
| 1562 | } |
| 1563 | |
| 1564 | |
| 1565 | // Internal method for optimizing traversal. Works like |