HTML Attribute Occurrence Last Wins
Apply an explicit last-occurrence-wins policy to supplied HTML attribute observations, preserving winning source indexes; browsers’ tokenizer normally uses first wins instead.
Description
Apply an explicit last-occurrence-wins policy to supplied HTML attribute observations, preserving winning source indexes; browsers’ tokenizer normally uses first wins instead.
Duplicate attribute observations need an explicit conflict policy. This tool deliberately keeps the last occurrence, which differs from normal browser tokenizer duplicate handling.
When to use this tool
Apply an explicit last-occurrence-wins policy to supplied HTML attribute observations, preserving winning source indexes; browsers’ tokenizer normally uses first wins instead.
- Prepare the supplied attributesJson fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter attributesJson. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.attributes. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Parse attributesJson as name/value objects, validate nonempty attribute names and ASCII-lowercase names. Keep only records with no later record of the same normalized name; return each winner with its original sourceIndex.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| attributesJson | JSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file. | Text |
For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.
[
{
"field": "attributesJson",
"decoded": [
{
"name": "ID",
"value": "a"
},
{
"name": "id",
"value": "b"
},
{
"name": "class",
"value": "c"
}
]
}
] | Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.attributes | The attributes list in the ordering and representation described above. |
{
"input": {
"attributesJson": "[{\"name\":\"ID\",\"value\":\"a\"},{\"name\":\"id\",\"value\":\"b\"},{\"name\":\"class\",\"value\":\"c\"}]"
},
"output": {
"result": {
"attributes": [
{
"name": "id",
"value": "b",
"sourceIndex": 1
},
{
"name": "class",
"value": "c",
"sourceIndex": 2
}
]
}
}
} Limitations and assumptions
- No HTML is parsed. Winners stay in source order, and this declared last-wins policy must not be mistaken for a browser's parsing rule.
- All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
- JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.
Alternative or Complementary methods
For actual document behavior, inspect a parsed DOM and the relevant HTML algorithm. These tools transform supplied tokens, observations or coordinates; compare the browser result when parsing or layout matters.
References
Similar or alternative tools
- HTML Attribute Occurrence Duplicate Audit
Audit duplicate attribute occurrences under HTML ASCII name lowercase without parsing a tag or losing duplicates; supplied occurrence indexes remain observable.
- aria state attribute pair checker
ARIA states expose changing interface conditions through defined attribute/value tokens.