forked from forgejo/forgejo
Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
f088dc4ea1
commit
86e2789960
819 changed files with 38072 additions and 34969 deletions
113
vendor/github.com/andybalholm/cascadia/selector.go
generated
vendored
113
vendor/github.com/andybalholm/cascadia/selector.go
generated
vendored
|
@ -16,14 +16,19 @@ type Matcher interface {
|
|||
}
|
||||
|
||||
// Sel is the interface for all the functionality provided by selectors.
|
||||
// It is currently the same as Matcher, but other methods may be added in the
|
||||
// future.
|
||||
type Sel interface {
|
||||
Matcher
|
||||
Specificity() Specificity
|
||||
|
||||
// Returns a CSS input compiling to this selector.
|
||||
String() string
|
||||
|
||||
// Returns a pseudo-element, or an empty string.
|
||||
PseudoElement() string
|
||||
}
|
||||
|
||||
// Parse parses a selector.
|
||||
// Parse parses a selector. Use `ParseWithPseudoElement`
|
||||
// if you need support for pseudo-elements.
|
||||
func Parse(sel string) (Sel, error) {
|
||||
p := &parser{s: sel}
|
||||
compiled, err := p.parseSelector()
|
||||
|
@ -38,7 +43,25 @@ func Parse(sel string) (Sel, error) {
|
|||
return compiled, nil
|
||||
}
|
||||
|
||||
// ParseWithPseudoElement parses a single selector,
|
||||
// with support for pseudo-element.
|
||||
func ParseWithPseudoElement(sel string) (Sel, error) {
|
||||
p := &parser{s: sel, acceptPseudoElements: true}
|
||||
compiled, err := p.parseSelector()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if p.i < len(sel) {
|
||||
return nil, fmt.Errorf("parsing %q: %d bytes left over", sel, len(sel)-p.i)
|
||||
}
|
||||
|
||||
return compiled, nil
|
||||
}
|
||||
|
||||
// ParseGroup parses a selector, or a group of selectors separated by commas.
|
||||
// Use `ParseGroupWithPseudoElements`
|
||||
// if you need support for pseudo-elements.
|
||||
func ParseGroup(sel string) (SelectorGroup, error) {
|
||||
p := &parser{s: sel}
|
||||
compiled, err := p.parseSelectorGroup()
|
||||
|
@ -53,6 +76,22 @@ func ParseGroup(sel string) (SelectorGroup, error) {
|
|||
return compiled, nil
|
||||
}
|
||||
|
||||
// ParseGroupWithPseudoElements parses a selector, or a group of selectors separated by commas.
|
||||
// It supports pseudo-elements.
|
||||
func ParseGroupWithPseudoElements(sel string) (SelectorGroup, error) {
|
||||
p := &parser{s: sel, acceptPseudoElements: true}
|
||||
compiled, err := p.parseSelectorGroup()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if p.i < len(sel) {
|
||||
return nil, fmt.Errorf("parsing %q: %d bytes left over", sel, len(sel)-p.i)
|
||||
}
|
||||
|
||||
return compiled, nil
|
||||
}
|
||||
|
||||
// A Selector is a function which tells whether a node matches or not.
|
||||
//
|
||||
// This type is maintained for compatibility; I recommend using the newer and
|
||||
|
@ -182,6 +221,10 @@ func (c tagSelector) Specificity() Specificity {
|
|||
return Specificity{0, 0, 1}
|
||||
}
|
||||
|
||||
func (c tagSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type classSelector struct {
|
||||
class string
|
||||
}
|
||||
|
@ -197,6 +240,10 @@ func (c classSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c classSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type idSelector struct {
|
||||
id string
|
||||
}
|
||||
|
@ -212,6 +259,10 @@ func (c idSelector) Specificity() Specificity {
|
|||
return Specificity{1, 0, 0}
|
||||
}
|
||||
|
||||
func (c idSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type attrSelector struct {
|
||||
key, val, operation string
|
||||
regexp *regexp.Regexp
|
||||
|
@ -352,6 +403,10 @@ func (c attrSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c attrSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ---------------- Pseudo class selectors ----------------
|
||||
// we use severals concrete types of pseudo-class selectors
|
||||
|
||||
|
@ -415,6 +470,10 @@ func (s relativePseudoClassSelector) Specificity() Specificity {
|
|||
return max
|
||||
}
|
||||
|
||||
func (c relativePseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type containsPseudoClassSelector struct {
|
||||
own bool
|
||||
value string
|
||||
|
@ -436,6 +495,10 @@ func (s containsPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c containsPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type regexpPseudoClassSelector struct {
|
||||
own bool
|
||||
regexp *regexp.Regexp
|
||||
|
@ -488,6 +551,10 @@ func (s regexpPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c regexpPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type nthPseudoClassSelector struct {
|
||||
a, b int
|
||||
last, ofType bool
|
||||
|
@ -623,6 +690,10 @@ func (s nthPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c nthPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type onlyChildPseudoClassSelector struct {
|
||||
ofType bool
|
||||
}
|
||||
|
@ -661,6 +732,10 @@ func (s onlyChildPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c onlyChildPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type inputPseudoClassSelector struct{}
|
||||
|
||||
// Matches input, select, textarea and button elements.
|
||||
|
@ -672,6 +747,10 @@ func (s inputPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c inputPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type emptyElementPseudoClassSelector struct{}
|
||||
|
||||
// Matches empty elements.
|
||||
|
@ -694,6 +773,10 @@ func (s emptyElementPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c emptyElementPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type rootPseudoClassSelector struct{}
|
||||
|
||||
// Match implements :root
|
||||
|
@ -711,8 +794,13 @@ func (s rootPseudoClassSelector) Specificity() Specificity {
|
|||
return Specificity{0, 1, 0}
|
||||
}
|
||||
|
||||
func (c rootPseudoClassSelector) PseudoElement() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type compoundSelector struct {
|
||||
selectors []Sel
|
||||
selectors []Sel
|
||||
pseudoElement string
|
||||
}
|
||||
|
||||
// Matches elements if each sub-selectors matches.
|
||||
|
@ -734,9 +822,17 @@ func (s compoundSelector) Specificity() Specificity {
|
|||
for _, sel := range s.selectors {
|
||||
out = out.Add(sel.Specificity())
|
||||
}
|
||||
if s.pseudoElement != "" {
|
||||
// https://drafts.csswg.org/selectors-3/#specificity
|
||||
out = out.Add(Specificity{0, 0, 1})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (c compoundSelector) PseudoElement() string {
|
||||
return c.pseudoElement
|
||||
}
|
||||
|
||||
type combinedSelector struct {
|
||||
first Sel
|
||||
combinator byte
|
||||
|
@ -818,6 +914,15 @@ func (s combinedSelector) Specificity() Specificity {
|
|||
return spec
|
||||
}
|
||||
|
||||
// on combinedSelector, a pseudo-element only makes sens on the last
|
||||
// selector, although others increase specificity.
|
||||
func (c combinedSelector) PseudoElement() string {
|
||||
if c.second == nil {
|
||||
return ""
|
||||
}
|
||||
return c.second.PseudoElement()
|
||||
}
|
||||
|
||||
// A SelectorGroup is a list of selectors, which matches if any of the
|
||||
// individual selectors matches.
|
||||
type SelectorGroup []Sel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue