mirror of
https://github.com/twitter/twemoji.git
synced 2024-11-02 11:30:12 +00:00
fixed non standard OSX behavior with variants
This commit is contained in:
parent
2b9415791c
commit
0a3a60d138
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "twemoji",
|
||||
"description": "A Unicode standard based way to implement emoji across all platforms.",
|
||||
"version": "v1.1.2",
|
||||
"version": "v1.2.0",
|
||||
"main": "./twemoji.amd.js",
|
||||
"ignore": [
|
||||
".git",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.1.2",
|
||||
"version": "1.2.0",
|
||||
"name": "twemoji",
|
||||
"license": ["MIT", "CC-BY-4.0"],
|
||||
"description": "A Unicode standard based way to implement emoji across all platforms.",
|
||||
|
22
test.js
22
test.js
@ -339,4 +339,26 @@ wru.test([{
|
||||
)
|
||||
);
|
||||
}
|
||||
},{
|
||||
name: 'non standard OSX variant',
|
||||
test: function () {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = '5\ufe0f\u20e3';
|
||||
twemoji.parse(div);
|
||||
wru.assert('recognized as graphical',
|
||||
div.innerHTML === '<img class="emoji" draggable="false" alt="5️⃣" src="http://twemoji.maxcdn.com/36x36/35-20e3.png">');
|
||||
wru.assert('the length is preserved',
|
||||
div.getElementsByTagName('img')[0].alt.length === 3);
|
||||
}
|
||||
},{
|
||||
name: 'same but standard OSX without variant',
|
||||
test: function () {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = '5\u20e3';
|
||||
twemoji.parse(div);
|
||||
wru.assert('recognized as graphical',
|
||||
div.innerHTML === '<img class="emoji" draggable="false" alt="5⃣" src="http://twemoji.maxcdn.com/36x36/35-20e3.png">');
|
||||
wru.assert('the length is preserved',
|
||||
div.getElementsByTagName('img')[0].alt.length === 2);
|
||||
}
|
||||
}]);
|
@ -578,7 +578,9 @@ function createTwemoji(re) {
|
||||
variant === '\uFE0F' ?
|
||||
// the icon should not contain it
|
||||
icon.slice(0, -1) :
|
||||
icon
|
||||
// fix non standard OSX behavior
|
||||
(icon.length === 3 && icon.charAt(1) === '\uFE0F' ?
|
||||
icon.charAt(0) + icon.charAt(2) : icon)
|
||||
);
|
||||
}
|
||||
|
||||
@ -793,6 +795,7 @@ function createTwemoji(re) {
|
||||
.replace(/^ /gm, '')
|
||||
// add the RegExp in the right place
|
||||
.replace('re = /twemoji/', 're = /' + re + '/g')
|
||||
.replace(/(\\u003[3-9])(\\u20e3)/g, '$1\\ufe0f?$2')
|
||||
// add the full license
|
||||
.replace('/*! (C) Twitter Inc. */',
|
||||
'/*! (C) Twitter Inc. *//*\n' +
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
twemoji.min.js
vendored
2
twemoji.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user