Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function prevGraphemeClusterBreak( str, fromIndex ) {
var cp;
var i;

var regexEmoji = new RegExp("\\p{Extended_Pictographic}", "ug");
var regexEmojiMatching = str.match(regexEmoji)
if (regexEmoji.test(str) && regexEmojiMatching && regexEmojiMatching.length === 1) {
str = regexEmojiMatching[0];
}

if ( !isString( str ) ) {
throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,12 @@ tape( 'the function returns -1 if provided an empty string', function test( t )

t.end();
});

tape( 'the function returns -1 if provided a skin tone emoji', function test( t ) {
var out;

out = prevGraphemeClusterBreak( '👉🏿' );
t.strictEqual( out, -1, 'returns expected value' );

t.end();
});