Closed
Description
Describe the bug
Something went wrong when I parsed the following code。
<template>
<view>
<image lazy />
<image></image>
</view>
</template>
The above code is parsed into something like this:
<template>
<view>
<image lazy="lazy">
<image/>
</image></view></template>
To Reproduce
https://stackblitz.com/edit/js-xmldom-template-cyojup?file=index.js
Expected behavior
<template>
<view>
<image lazy="lazy"/>
<image/>
</view>
</template>
Runtime & Version:
xmldom version: 0.8.6
runtime version: 0.8.6
other related software and version:
Additional context
I tried to solve the problem myself, until I changed the code in @xmldom/xmldom/lib/sax.js
in such a way that it could parse properly。
case '/':
switch(s){
case S_TAG:
el.setTagName(source.slice(start,p));
case S_ATTR_END:
case S_TAG_SPACE:
case S_TAG_CLOSE:
s =S_TAG_CLOSE;
el.closed = true;
case S_ATTR_NOQUOT_VALUE:
case S_ATTR:
- // case S_ATTR_SPACE:
break;
+ case S_ATTR_SPACE:
+ el.closed = true;
+ break;
//case S_EQ:
default:
throw new Error("attribute invalid close char('/')") // No known test case
}
break;
Finally, I put up the pull request, I don't know whether my solution is right or not, so you can check it when you are free.
Thanks.