github.com/evanw/esbuild@v0.21.4/internal/css_parser/css_decls_container.go (about) 1 package css_parser 2 3 import ( 4 "strings" 5 6 "github.com/evanw/esbuild/internal/css_ast" 7 "github.com/evanw/esbuild/internal/css_lexer" 8 ) 9 10 // Scan for container names in the "container" shorthand property 11 func (p *parser) processContainerShorthand(tokens []css_ast.Token) { 12 // Validate the syntax 13 for i, t := range tokens { 14 if t.Kind == css_lexer.TIdent { 15 continue 16 } 17 if t.Kind == css_lexer.TDelimSlash && i+2 == len(tokens) && tokens[i+1].Kind == css_lexer.TIdent { 18 break 19 } 20 return 21 } 22 23 // Convert any local names 24 for i, t := range tokens { 25 if t.Kind != css_lexer.TIdent { 26 break 27 } 28 p.handleSingleContainerName(&tokens[i]) 29 } 30 } 31 32 func (p *parser) processContainerName(tokens []css_ast.Token) { 33 // Validate the syntax 34 for _, t := range tokens { 35 if t.Kind != css_lexer.TIdent { 36 return 37 } 38 } 39 40 // Convert any local names 41 for i := range tokens { 42 p.handleSingleContainerName(&tokens[i]) 43 } 44 } 45 46 func (p *parser) handleSingleContainerName(token *css_ast.Token) { 47 if lower := strings.ToLower(token.Text); lower == "none" || cssWideAndReservedKeywords[lower] { 48 return 49 } 50 51 token.Kind = css_lexer.TSymbol 52 token.PayloadIndex = p.symbolForName(token.Loc, token.Text).Ref.InnerIndex 53 }