question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Remove usage of Function() to load the XPathParser_raw

See original GitHub issue

We use fontoxpath in the browser and due to the use of Function when loading the generated XPath Parser we have to set unsafe-eval on our script sources CSP, which isn’t particularly ideal.

Is it possible for the generated parser to be built and imported in a more standard way? Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DrRataplancommented, May 10, 2021

I just integrated the PR. I’m making a new release right now.

1reaction
DrRataplancommented, Apr 22, 2021

Hey @ymor,

We have that new Function shenanigan because of historic reasons. This repo used to be a pure Closure Compiler project which, at the time, had no way of disabling the compiler for specific files. So we had to resort to evaluating a string, yadayadayada

Now that we use TypeScript, there exists the // @ts-ignore flag, which does work.

I gave this another try, and it worked. Furthermore, I saw a 10kB reduction in the overall filesize of the esm bundle of FontoXPath: 385kB -> 375kB, which is imho pretty significant. It also removes the dependency on uglifyJS, which is admirable in itself!

Thanks for pointing this out!

Regards,

Martin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove and RemoveIf functions in Power Apps
Use the Remove function to remove a specific record or records from a data source. For collections, the entire record must match.
Read more >
Adding and Removing Event Listeners with parameters
cleanUpMyListener () ... Step 3) Use the function reference to remove the listener ... When the event is fired, call the wrapping function...
Read more >
remove_action() | Function - WordPress Developer Resources
Description. This can be used to remove default functions attached to a specific action hook and possibly replace them with a substitute. To...
Read more >
Removing Event Listeners with removeEventListener()
In order to use the removeEventListener() method, we need to use a function declaration, or store our function expression into a variable ...
Read more >
EventTarget.removeEventListener() - Web APIs | MDN
The event listener function of the event handler to remove from the ... wise to use the same values used for the call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found