github.com/MontFerret/ferret@v0.18.0/pkg/drivers/common/attrs.go (about)

     1  package common
     2  
     3  import "strings"
     4  
     5  var Attributes = []string{
     6  	"abbr",
     7  	"accept",
     8  	"accept-charset",
     9  	"accesskey",
    10  	"action",
    11  	"allowfullscreen",
    12  	"allowpaymentrequest",
    13  	"allowusermedia",
    14  	"alt",
    15  	"as",
    16  	"async",
    17  	"autocomplete",
    18  	"autofocus",
    19  	"autoplay",
    20  	"challenge",
    21  	"charset",
    22  	"checked",
    23  	"cite",
    24  	"class",
    25  	"color",
    26  	"cols",
    27  	"colspan",
    28  	"command",
    29  	"content",
    30  	"contenteditable",
    31  	"contextmenu",
    32  	"controls",
    33  	"coords",
    34  	"crossorigin",
    35  	"data",
    36  	"datetime",
    37  	"default",
    38  	"defer",
    39  	"dir",
    40  	"dirname",
    41  	"disabled",
    42  	"download",
    43  	"draggable",
    44  	"dropzone",
    45  	"enctype",
    46  	"for",
    47  	"form",
    48  	"formaction",
    49  	"formenctype",
    50  	"formmethod",
    51  	"formnovalidate",
    52  	"formtarget",
    53  	"headers",
    54  	"height",
    55  	"hidden",
    56  	"high",
    57  	"href",
    58  	"hreflang",
    59  	"http-equiv",
    60  	"icon",
    61  	"id",
    62  	"inputmode",
    63  	"integrity",
    64  	"is",
    65  	"ismap",
    66  	"itemid",
    67  	"itemprop",
    68  	"itemref",
    69  	"itemscope",
    70  	"itemtype",
    71  	"keytype",
    72  	"kind",
    73  	"label",
    74  	"lang",
    75  	"list",
    76  	"loop",
    77  	"low",
    78  	"manifest",
    79  	"max",
    80  	"maxlength",
    81  	"media",
    82  	"mediagroup",
    83  	"method",
    84  	"min",
    85  	"minlength",
    86  	"multiple",
    87  	"muted",
    88  	"name",
    89  	"nomodule",
    90  	"nonce",
    91  	"novalidate",
    92  	"open",
    93  	"optimum",
    94  	"pattern",
    95  	"ping",
    96  	"placeholder",
    97  	"playsinline",
    98  	"poster",
    99  	"preload",
   100  	"radiogroup",
   101  	"readonly",
   102  	"referrerpolicy",
   103  	"rel",
   104  	"required",
   105  	"reversed",
   106  	"rows",
   107  	"rowspan",
   108  	"sandbox",
   109  	"spellcheck",
   110  	"scope",
   111  	"scoped",
   112  	"seamless",
   113  	"selected",
   114  	"shape",
   115  	"size",
   116  	"sizes",
   117  	"sortable",
   118  	"sorted",
   119  	"slot",
   120  	"span",
   121  	"spellcheck",
   122  	"src",
   123  	"srcdoc",
   124  	"srclang",
   125  	"srcset",
   126  	"start",
   127  	"step",
   128  	"style",
   129  	"tabindex",
   130  	"target",
   131  	"title",
   132  	"translate",
   133  	"type",
   134  	"typemustmatch",
   135  	"updateviacache",
   136  	"usemap",
   137  	"value",
   138  	"width",
   139  	"workertype",
   140  	"wrap",
   141  }
   142  
   143  const (
   144  	AttrNameStyle = "style"
   145  )
   146  
   147  var attrMap = make(map[string]bool)
   148  
   149  func init() {
   150  	for _, attr := range Attributes {
   151  		attrMap[attr] = true
   152  	}
   153  }
   154  
   155  func IsAttribute(name string) bool {
   156  	_, isDefault := attrMap[name]
   157  
   158  	if isDefault {
   159  		return true
   160  	}
   161  
   162  	return strings.HasPrefix(name, "data-") ||
   163  		strings.HasPrefix(name, "aria-")
   164  }