Merge pull request #17596 from nicolo-ribaudo/fix-babel-plugin
Fix transform of unary expression in Babel plugin
This commit is contained in:
commit
56dabe9390
@ -92,9 +92,13 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
|
||||
}
|
||||
},
|
||||
},
|
||||
UnaryExpression(path) {
|
||||
UnaryExpression: {
|
||||
exit(path) {
|
||||
const { node } = path;
|
||||
if (node.operator === "typeof" && isPDFJSPreprocessor(node.argument)) {
|
||||
if (
|
||||
node.operator === "typeof" &&
|
||||
isPDFJSPreprocessor(node.argument)
|
||||
) {
|
||||
// typeof PDFJSDev => 'object'
|
||||
path.replaceWith(t.stringLiteral("object"));
|
||||
return;
|
||||
@ -104,6 +108,7 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
|
||||
path.replaceWith(t.booleanLiteral(!node.argument.value));
|
||||
}
|
||||
},
|
||||
},
|
||||
LogicalExpression: {
|
||||
exit(path) {
|
||||
const { node } = path;
|
||||
|
@ -17,3 +17,5 @@ var i = '0';
|
||||
var j = {
|
||||
i: 1
|
||||
};
|
||||
var k = false;
|
||||
var l = true;
|
||||
|
2
external/builder/fixtures_esprima/evals.js
vendored
2
external/builder/fixtures_esprima/evals.js
vendored
@ -8,3 +8,5 @@ var g = PDFJSDev.eval('OBJ');
|
||||
var h = PDFJSDev.json('$ROOT/external/builder/fixtures_esprima/evals.json');
|
||||
var i = typeof PDFJSDev === 'undefined' ? PDFJSDev.eval('FALSE') : '0';
|
||||
var j = typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('OBJ.obj') : '0';
|
||||
var k = !PDFJSDev.test('TRUE');
|
||||
var l = !PDFJSDev.test('FALSE');
|
||||
|
@ -400,7 +400,7 @@ class ExternalServices extends BaseExternalServices {
|
||||
}
|
||||
|
||||
async getNimbusExperimentData() {
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("GECKOVIEW")) {
|
||||
if (!PDFJSDev.test("GECKOVIEW")) {
|
||||
return null;
|
||||
}
|
||||
const nimbusData = await FirefoxCom.requestAsync(
|
||||
|
Loading…
Reference in New Issue
Block a user