From 7eb4cc4903964c390d57039eda15511b33515f39 Mon Sep 17 00:00:00 2001 From: 5saviahv <49443574+5saviahv@users.noreply.github.com> Date: Sun, 7 Feb 2021 20:10:01 +0200 Subject: [PATCH] feat(parse): Expose parse5 option scriptingEnabled (#1707) * expose parse5 option scriptingEnabled * parse5 options test * add option scriptingEnabled into types * typo in comment Co-authored-by: 5saviahv <5saviahv@users.noreply.github.com> --- lib/parsers/parse5.js | 4 +++ test/__fixtures__/fixtures.js | 10 ++++++ test/cheerio.js | 64 +++++++++++++++++++++++++++++++++++ types/index.d.ts | 3 ++ types/index.test-d.ts | 8 +++++ 5 files changed, 89 insertions(+) diff --git a/lib/parsers/parse5.js b/lib/parsers/parse5.js index 870103c3f5..e20bc84419 100644 --- a/lib/parsers/parse5.js +++ b/lib/parsers/parse5.js @@ -4,6 +4,10 @@ var htmlparser2Adapter = require('parse5-htmlparser2-tree-adapter'); exports.parse = function (content, options, isDocument) { var opts = { + scriptingEnabled: + typeof options.scriptingEnabled === 'boolean' + ? options.scriptingEnabled + : true, treeAdapter: htmlparser2Adapter, sourceCodeLocationInfo: options.sourceCodeLocationInfo, }; diff --git a/test/__fixtures__/fixtures.js b/test/__fixtures__/fixtures.js index 79f85ca3f0..e232515c1c 100644 --- a/test/__fixtures__/fixtures.js +++ b/test/__fixtures__/fixtures.js @@ -84,3 +84,13 @@ exports.forms = [ '
', '', ].join(''); + +exports.noscript = [ + '