Force unorm shim when String.prototype.normalize is broken (#338).
This commit is contained in:
parent
fad902b438
commit
478aaf9619
2
dist/shims.js
vendored
2
dist/shims.js
vendored
File diff suppressed because one or more lines are too long
12
gulpfile.js
12
gulpfile.js
@ -152,7 +152,9 @@ function taskBundle(name, options) {
|
||||
if (options.minify) {
|
||||
result = result.pipe(buffer())
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(uglify())
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(sourcemaps.write('./'))
|
||||
}
|
||||
|
||||
@ -190,7 +192,9 @@ gulp.task('shims', function () {
|
||||
.bundle()
|
||||
.pipe(source('shims.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify())
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
|
||||
return result;
|
||||
@ -287,7 +291,9 @@ function taskLang(locale) {
|
||||
.bundle()
|
||||
.pipe(source("wordlist-" + locale + ".js"))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify())
|
||||
.pipe(uglify({
|
||||
output: { ascii_only: true }
|
||||
}))
|
||||
.pipe(gulp.dest("dist"));
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
// Shim String.prototype.normalize
|
||||
var unorm = require('./unorm.js');
|
||||
try {
|
||||
// Some platforms have a native normalize, but it is broken; so we force our shim
|
||||
if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error('bad normalize');
|
||||
}
|
||||
} catch (error) {
|
||||
var unorm = require('./unorm.js');
|
||||
console.log("Broken String.prototype.normalize... Forcing shim.");
|
||||
String.prototype.normalize = function(form) {
|
||||
var func = unorm[(form || 'NFC').toLowerCase()];
|
||||
if (!func) { throw new RangeError('invalid form - ' + form); }
|
||||
return func(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Shim atob and btoa
|
||||
var base64 = require('./base64.js');
|
||||
|
Loading…
Reference in New Issue
Block a user