2.5.17
https://jsfiddle.net/sf9cg0db/
Try to dynamically load an input field with a value that contains an encoded single quote (') as plain HTML. Normally the input field will display the single quote in the input box. However, Vue shows the ' in the input box.
I tested this with multiple encoded chars, and everything works correctly, except for the single quote. As stated by @HcySunYang, all entities except the 6 he listed have this issue.
A single quote is shown in the input field when loaded async with Vue
' is show in the input field when loaded async with Vue
This is not related to whether the component is asynchronous or not. Non-asynchronous components also have this problem. Vue's html-parser will only process the following entity content:
const decodingMap = {
'<': '<',
'>': '>',
'"': '"',
'&': '&',
' ': '\n',
'	': '\t'
}
it's here: https://github.com/vuejs/vue/blob/dev/src/compiler/parser/html-parser.js#L38-L45.
So ''' should be added to the map?
Update: https://jsfiddle.net/sf9cg0db/12/
You are right, also é for example doesn't work... So if manually 6 out of all entities are correctly converted, how should this be fixed then?
It would not be better to use something like this package?
https://github.com/mdevils/node-html-entities
Actually Vue is already using he on Node.js (compile-time and SSR) and leveraging DOM API on the browser side to perform entity decoding. It seems that only attribute values are decoded using the decodingMap mentioned above and I'm not sure it's intentional or just a miss.
Most helpful comment
Actually Vue is already using
heon Node.js (compile-time and SSR) and leveraging DOM API on the browser side to perform entity decoding. It seems that only attribute values are decoded using thedecodingMapmentioned above and I'm not sure it's intentional or just a miss.