Yorick Peterse
2c4e490614
Added CSS/XPath Parser.parse_with_cache
...
This method parses and caches ASTs using Oga::LRU. Currently the default
of 1024 keys is used.
See #71 for more information.
2015-03-23 00:22:59 +01:00
Yorick Peterse
70e4942d3e
CSS parser spec for "+ b"
2015-03-21 01:23:00 +01:00
Yorick Peterse
47a3c5e7f8
Use describe/it instead of context/example.
...
This keeps things consistent with the general testing guidelines in the Ruby
community. This in turn should hopefully make my life easier as I don't have to
tell people to use this rather odd stlye I was using before.
2015-01-08 23:01:53 +01:00
Yorick Peterse
448ff56e38
Fixed CSS eval specs for nth-(first|last)-of-type.
2014-11-15 18:27:26 +01:00
Yorick Peterse
b464815577
Fixed AST generation for nth-(first|last)-of-type.
2014-11-15 18:27:15 +01:00
Yorick Peterse
9eead81a7c
Fixed AST for :only-of-type
2014-11-15 18:08:26 +01:00
Yorick Peterse
1c301d40e2
Properly fixed AST for first-of-type/last-of-type
...
This requires keeping track of the current element being processed. This in turn
allows the usage of count() + preceding-sibling/following-sibling.
2014-11-15 17:58:56 +01:00
Yorick Peterse
e559b4b89b
Corrected :first-of-type eval spec.
2014-11-15 17:20:17 +01:00
Yorick Peterse
6daa3e7a00
Reverted AST changes for first-of-type
...
Functions can't be used in combination with axes, so I'll just need to fix the
position() function to work properly.
2014-11-14 23:51:46 +01:00
Yorick Peterse
2d6a2be2e8
Revert "Fixed XPath AST for :last-of-type"
...
Axes can't be used in combination with functions.
This reverts commit b0b572a584 .
2014-11-14 23:49:49 +01:00
Yorick Peterse
8f3553f8f1
Fixed eval specs of :first-of-type & :last-of-type
2014-11-14 23:27:52 +01:00
Yorick Peterse
b0b572a584
Fixed XPath AST for :last-of-type
...
This should count following nodes, not merely the position.
2014-11-14 23:27:15 +01:00
Yorick Peterse
0128dc50ae
Fixed CSS evaluation of :first-of-type
...
The old XPath "position() = 1" would work in Nokogiri due to the way they
retrieve descendants. In Oga however this would simply always return the first
node.
To fix this Oga now counts the amount of preceding siblings that match the same
full name.
2014-11-14 01:25:03 +01:00
Yorick Peterse
d47ca19ffa
Remaining CSS evaluation specs.
2014-11-14 00:24:54 +01:00
Yorick Peterse
518bedc3a1
CSS evaluator specs for :nth-of-type
2014-11-14 00:16:35 +01:00
Yorick Peterse
abfe6e3d61
CSS evaluator specs for nth-last-of-type
2014-11-14 00:13:11 +01:00
Yorick Peterse
c874ceabb9
CSS evaluator specs for :nth-last-child
2014-11-13 23:54:47 +01:00
Yorick Peterse
5964a2cda4
CSS evaluator specs for :nth-child(n)
2014-11-13 22:50:04 +01:00
Yorick Peterse
3237617bf5
CSS eval specs for various pseudo classes.
...
This includes the following pseudos:
* :empty
* :first-child
* :first-of-type
* :last-child
* :last-of-type
2014-11-13 10:10:31 +01:00
Yorick Peterse
97a9a11db1
Failing CSS evaluation specs for the axes.
...
These currently fail due to the ~ and + axes not being evaluated properly.
2014-11-12 23:38:17 +01:00
Yorick Peterse
c15604a86f
CSS evaluator specs for IDs.
2014-11-11 00:21:28 +01:00
Yorick Peterse
b9e1b51270
CSS evaluator specs for classes.
2014-11-11 00:18:44 +01:00
Yorick Peterse
43200238c5
CSS evaluator specs for predicates and operators.
2014-11-10 23:21:00 +01:00
Yorick Peterse
1f855dc982
Rewrote CSS evaluator paths spec.
2014-11-09 23:51:23 +01:00
Yorick Peterse
7e38e20586
Use "include" vs "return" in CSS path spec.
2014-11-07 09:28:18 +01:00
Yorick Peterse
a586a512b8
Removed support for CSS such as "|X"
...
This expression could be used to get all elements that _don't_ have any
namespace. The problem is that this can't be expressed as just a node test,
instead the resulting XPath would have to look something like the following:
X[local-name() = name()]
However, since the XPath predicates are already created for pseudo classes and
such, also injecting the above into it would be a real big pain. As such I've
decided not to support it.
2014-11-05 00:45:40 +01:00
Yorick Peterse
661741268a
CSS parser tests for paths with namespaces.
2014-11-05 00:44:23 +01:00
Yorick Peterse
61801fe562
Allow CSS identifiers to start with an underscore.
2014-11-05 00:37:40 +01:00
Yorick Peterse
eb3a3e7630
Use the descendant axis for CSS selectors.
...
Instead of using "descendant-or-self" Oga will use "descendant". This ensures
that expressions such as "foo *" don't return a set also including the "foo"
element.
Nokogiri solves this problem in a somewhat different way by using //foo//* for
the CSS expression "foo *". While this works in Nokogiri the expression
"descendant-or-self::node()" is slow as a snail in Oga (due to its nature of
retrieving _all_ nodes first). By using "descendant" we can work around this
problem.
2014-11-05 00:22:09 +01:00
Yorick Peterse
1f3b4cb2fb
Added initial CSS evaluation tests.
2014-11-04 23:34:01 +01:00
Yorick Peterse
de04c61df9
Parsing support for the :empty pseudo.
2014-11-04 00:00:23 +01:00
Yorick Peterse
1b870406de
Parsing support for the :only-of-type pseudo.
2014-11-03 23:47:25 +01:00
Yorick Peterse
2cf058457d
Parsing support for the :only-child pseudo.
2014-11-03 23:27:56 +01:00
Yorick Peterse
759bb71d17
Parsing support for the :last-of-type pseudo.
2014-11-03 23:01:44 +01:00
Yorick Peterse
10632eafd4
Parsing support for the :first-of-type pseudo.
2014-11-03 23:00:15 +01:00
Yorick Peterse
7a606a11d3
Parsing support for the :last-child pseudo class.
2014-11-03 22:58:08 +01:00
Yorick Peterse
b4fec3cc8c
Parsing support for the :first-child pseudo class.
2014-11-03 22:45:00 +01:00
Yorick Peterse
020d979fba
Parsing support for :nth-last-of-type().
2014-11-03 22:15:21 +01:00
Yorick Peterse
ab8b451dc3
Parsing support for :nth-of-type()
2014-11-02 19:29:39 +01:00
Yorick Peterse
0faceffacb
Parsing support for nth-child(n+X)
2014-11-02 19:29:09 +01:00
Yorick Peterse
8d8d74ec41
Drop nth-child support of all negative sequences
...
This removes parsing support for selectors such as :nth-child(-n-6). According
to the CSS spec this isn't valid anyway (confirmed by testing it in Chromium).
As a result there's no point in supporting it in any way.
2014-11-02 19:19:05 +01:00
Yorick Peterse
b31288b7d2
Use correct modulo for nth-child and negatives.
2014-11-02 18:53:23 +01:00
Yorick Peterse
9cce93fc4a
Parsing support for :nth-last-child.
2014-11-01 20:58:28 +01:00
Yorick Peterse
64f9c570fa
Use separate spec files for each pseudo class.
2014-11-01 20:20:33 +01:00
Yorick Peterse
03f897c2b7
Support for all possible nth-child arguments.
...
That is, as far as I can tell based on Nokogiri's behaviour (which Oga now
matches).
2014-10-30 23:03:46 +01:00
Yorick Peterse
0e6aefb727
Fixed parsing of nth-child(n) and nth-child(-n)
2014-10-30 00:24:31 +01:00
Yorick Peterse
87f6b9c723
Basic support for :nth-child()
...
This already includes support for formulas such as 2n, odd, even and 2n+1.
Negative formulas, just "n" and others are not yet supported.
2014-10-28 00:21:11 +01:00
Yorick Peterse
39c0f7147c
Support for parsing the :root pseudo class.
2014-10-26 22:20:23 +01:00
Yorick Peterse
32764c9a14
Proper parsing support for all CSS operators.
2014-10-26 12:45:43 +01:00
Yorick Peterse
7ee7f25239
Support for parsing CSS axes.
2014-10-23 00:42:45 +02:00