-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attr
adds duplicate namespaced attribute in 1.0.0-rc.5
#1713
Comments
It seems to working fine: const cheerio = require('cheerio');
const template = `<a transform="translate(1135.9 750)" fill="#5293d5" xlink:href="https://certificateUrl">
<text id="certificateUrl" transform="scale(1,-1)" x="242.74602" y="545.25012" fill="#5293d5" font-family="'Open Sans'" font-size="100px" letter-spacing="0px" stroke-width="7.5" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve">
<tspan x="242.74602" y="545.25012" fill="#5293d5" font-family="'Open Sans'" font-size="100px" stroke-width="7.5" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">https://certificateUrl</tspan>
</text>
</a>`;
const $ = cheerio.load(template), data = {};
// WARNING: in cheerio 1.0.0-rc.3 this worked properly, in cheerio 1.0.0-rc.5 it will clear the tag's contents
const url = $('a[xlink\\:href]').attr('xlink:href', data.certificateUrl);
console.log(url); results:
I compared rc.3 & rc.5 and it behaves very similarly - cant see where content may be lost. |
attr
removes contents of elements in 1.0.0-rc.5attr
adds duplicate namespaced attribute in 1.0.0-rc.5
Thanks @5saviahv , I've revised the title and description (my initial diagnosis was incorrect, but there's still this bug), with illustration of which attributes are wrong. |
|
yes that's correct, this happens with namespaced attributes only |
I just tried to replicate this on the latest version: const d = $.load(
`<a xlink:href="https://certificateUrl"><text xml:space="preserve"></text></a>`,
null,
false
);
d('a').attr('xlink:href', 'boohoo');
expect(d.html()).toBe(
`<a xlink:href="boohoo"><text xml:space="preserve"></text></a>`
); Looks like this issue has been resolved. |
Example:
Code:
Please fix this behavior of
attr
like jQuery.Related to #1664.
Result:
In 1.0.0-rc.3:
xlink:href
, it creates another attributehref
but properly setting thexlink:href
onefont-family
xml:space
get turned into ->space
In 1.0.0-rc.5:
xlink:href
, it creates another attribute with same namexlink:href
making that attribute duplicate and thus invalid XMLfont-family
andxml:space
The text was updated successfully, but these errors were encountered: