mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
excluding nodeType 1 SVG elements too
This commit is contained in:
parent
f5ca4f51f9
commit
3c0c13d3a5
21
test.js
21
test.js
@ -514,4 +514,25 @@ wru.test([{
|
|||||||
wru.assert('correct length', div.getElementsByTagName('img').length === 0);
|
wru.assert('correct length', div.getElementsByTagName('img').length === 0);
|
||||||
wru.assert('expected html', div.innerHTML === '"\u2b1c\uFE0E"');
|
wru.assert('expected html', div.innerHTML === '"\u2b1c\uFE0E"');
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
name: 'SVG Elements are ignored',
|
||||||
|
test: function () {
|
||||||
|
if (typeof SVGElement !== 'undefined') {
|
||||||
|
var innerHTML, div = document.createElement('div');
|
||||||
|
div.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40">' +
|
||||||
|
'<switch>' +
|
||||||
|
'<circle cx="20" cy="20" r="18" stroke="grey" stroke-width="2" fill="#99FF66" />' +
|
||||||
|
'<foreignObject>' +
|
||||||
|
'<div>I \u2764 emoji!</div>' +
|
||||||
|
'</foreignObject>' +
|
||||||
|
'</switch>' +
|
||||||
|
'</svg>';
|
||||||
|
// grab the normalized one
|
||||||
|
innerHTML = div.innerHTML;
|
||||||
|
twemoji.parse(div);
|
||||||
|
wru.assert('nothing changed', innerHTML === div.innerHTML);
|
||||||
|
} else {
|
||||||
|
wru.assert('nothing to do here');
|
||||||
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
@ -516,8 +516,8 @@ function createTwemoji(re) {
|
|||||||
// used to find HTML special chars in attributes
|
// used to find HTML special chars in attributes
|
||||||
rescaper = /[&<>'"]/g,
|
rescaper = /[&<>'"]/g,
|
||||||
|
|
||||||
// nodes with type 1 which should **not** be parsed
|
// nodes with type 1 which should **not** be parsed (including lower case svg)
|
||||||
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA/,
|
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
|
||||||
|
|
||||||
// just a private shortcut
|
// just a private shortcut
|
||||||
fromCharCode = String.fromCharCode;
|
fromCharCode = String.fromCharCode;
|
||||||
|
@ -239,8 +239,8 @@ define(function () {
|
|||||||
// used to find HTML special chars in attributes
|
// used to find HTML special chars in attributes
|
||||||
rescaper = /[&<>'"]/g,
|
rescaper = /[&<>'"]/g,
|
||||||
|
|
||||||
// nodes with type 1 which should **not** be parsed
|
// nodes with type 1 which should **not** be parsed (including lower case svg)
|
||||||
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA/,
|
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
|
||||||
|
|
||||||
// just a private shortcut
|
// just a private shortcut
|
||||||
fromCharCode = String.fromCharCode;
|
fromCharCode = String.fromCharCode;
|
||||||
|
@ -238,8 +238,8 @@ var twemoji = (function (
|
|||||||
// used to find HTML special chars in attributes
|
// used to find HTML special chars in attributes
|
||||||
rescaper = /[&<>'"]/g,
|
rescaper = /[&<>'"]/g,
|
||||||
|
|
||||||
// nodes with type 1 which should **not** be parsed
|
// nodes with type 1 which should **not** be parsed (including lower case svg)
|
||||||
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA/,
|
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
|
||||||
|
|
||||||
// just a private shortcut
|
// just a private shortcut
|
||||||
fromCharCode = String.fromCharCode;
|
fromCharCode = String.fromCharCode;
|
||||||
|
2
twemoji.min.js
vendored
2
twemoji.min.js
vendored
File diff suppressed because one or more lines are too long
@ -239,8 +239,8 @@ var twemoji = (function (
|
|||||||
// used to find HTML special chars in attributes
|
// used to find HTML special chars in attributes
|
||||||
rescaper = /[&<>'"]/g,
|
rescaper = /[&<>'"]/g,
|
||||||
|
|
||||||
// nodes with type 1 which should **not** be parsed
|
// nodes with type 1 which should **not** be parsed (including lower case svg)
|
||||||
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA/,
|
shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
|
||||||
|
|
||||||
// just a private shortcut
|
// just a private shortcut
|
||||||
fromCharCode = String.fromCharCode;
|
fromCharCode = String.fromCharCode;
|
||||||
|
Loading…
Reference in New Issue
Block a user