mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Expand HTML entities in title attribute
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1074
This commit is contained in:
parent
c0edebb28a
commit
d3a524b9be
1 changed files with 7 additions and 3 deletions
|
|
@ -69,7 +69,7 @@ const safeTextToTagNode = function(text) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const safeTextToTextNode = (function() {
|
const expandHtmlEntities = (( ) => {
|
||||||
const entities = new Map([
|
const entities = new Map([
|
||||||
// TODO: Remove quote entities once no longer present in translation
|
// TODO: Remove quote entities once no longer present in translation
|
||||||
// files. Other entities must stay.
|
// files. Other entities must stay.
|
||||||
|
|
@ -88,10 +88,14 @@ const safeTextToTextNode = (function() {
|
||||||
if ( text.indexOf('&') !== -1 ) {
|
if ( text.indexOf('&') !== -1 ) {
|
||||||
text = text.replace(/&[a-z]+;/g, decodeEntities);
|
text = text.replace(/&[a-z]+;/g, decodeEntities);
|
||||||
}
|
}
|
||||||
return document.createTextNode(text);
|
return text;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const safeTextToTextNode = function(text) {
|
||||||
|
return document.createTextNode(expandHtmlEntities(text));
|
||||||
|
};
|
||||||
|
|
||||||
const safeTextToDOM = function(text, parent) {
|
const safeTextToDOM = function(text, parent) {
|
||||||
if ( text === '' ) { return; }
|
if ( text === '' ) { return; }
|
||||||
|
|
||||||
|
|
@ -221,7 +225,7 @@ vAPI.i18n.render = function(context) {
|
||||||
for ( const elem of root.querySelectorAll('[data-i18n-title]') ) {
|
for ( const elem of root.querySelectorAll('[data-i18n-title]') ) {
|
||||||
const text = vAPI.i18n(elem.getAttribute('data-i18n-title'));
|
const text = vAPI.i18n(elem.getAttribute('data-i18n-title'));
|
||||||
if ( !text ) { continue; }
|
if ( !text ) { continue; }
|
||||||
elem.setAttribute('title', text);
|
elem.setAttribute('title', expandHtmlEntities(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const elem of root.querySelectorAll('[placeholder]') ) {
|
for ( const elem of root.querySelectorAll('[placeholder]') ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue