dianping/cat · error · Error
attribute invalid close char('/')
Error message
attribute invalid close char('/') What it means
A '/' encountered inside a start tag in a state where self-closing is not meaningful (worker-xml.js:~1556). The '/' case tolerates states S_TAG..S_ATTR_S (empty-element close after tag name or attributes) but any other state — notably S_EQ, i.e. '/' immediately after '=' with no value — hits the default and throws.
Source
Thrown at cat-home/src/main/webapp/assets/js/editor/worker-xml.js:1556
}else{
throw new Error('attribute value must after "="');
}
break;
case '/':
switch(s){
case S_TAG:
el.setTagName(source.slice(start,p));
case S_E:
case S_S:
case S_C:
s = S_C;
el.closed = true;
case S_V:
case S_ATTR:
case S_ATTR_S:
break;
default:
throw new Error("attribute invalid close char('/')")
}
break;
case ''://end document
errorHandler.error('unexpected end of input');
case '>':
switch(s){
case S_TAG:
el.setTagName(source.slice(start,p));
case S_E:
case S_S:
case S_C:
break;//normal
case S_V://Compatible state
case S_ATTR:
value = source.slice(start,p);
if(value.slice(-1) === '/'){
el.closed = true;
value = value.slice(0,-1)View on GitHub (pinned to e815e74d4c)
Solutions
- Complete the attribute value before the slash: <a href="#"/> or drop the attribute.
- If the tag should be empty, remove the dangling 'attr=' part entirely.
- Re-check the tag after finishing the edit — this is often a transient mid-keystroke state.
Example fix
<!-- before --> <img src=/> <!-- after --> <img src="placeholder.png"/>
Defensive patterns
Strategy: validation
Validate before calling
// No '/' may directly follow '=' inside a start tag:
function noSlashAfterEquals(tagText) {
return !/=\s*\//.test(tagText);
} Try / catch
try {
parseStartTag(source, start, tagNameReplacer);
} catch (ex) {
if (/invalid close char/.test(ex.message)) reportXmlError(ex); else throw ex;
} Prevention
- Finish attribute values before typing '/>'.
- Delete dangling 'attr=' if the attribute is unused.
- Let the editor's autoclose produce '/>' atomically.
When it happens
Trigger: '<a href=/> ...' (self-closing right after '='), or a slash embedded mid-attribute in a state the switch doesn't list. The case '/' default at line 1552-1555 throws.
Common situations: Typing an empty-element tag and the worker parses before the value is written; HTML like '<br/>' pasted with a mangled attribute ('<img src=/>'); templating that collapses an attribute value to nothing.
Related errors
- elements closed character '/' and '>' must be connected to
- attribute equal must after attrName
- attribute value must after "="
- attribute value missed!!
- invalid tagName:{tagName}
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/2bc7615d4ec801c6.
Report an issue: GitHub.