GithubHelp home page GithubHelp logo

Comments (5)

ismail-codar avatar ismail-codar commented on August 20, 2024

Is the regexp usage unnecessary here. We want to exact match on this line and can be as var svg = svg || SvgOnlyTags.indexOf(tag)!= -1

from surplus.

adamhaile avatar adamhaile commented on August 20, 2024

It's a single char typo. In SvgOnlyTagRx, the $ anchoring the end of the match is inside the parens when it should be outside. So it only anchors the last tag, not all of them. I'm away camping with the family but will fix it as soon as I'm back.

from surplus.

ismail-codar avatar ismail-codar commented on August 20, 2024

No hurry! sometimes need to raise head from the computer. I can go on with these kind of things I've done in my own repository. The following code can provide convenience for simulating the problem.

var SvgOnlyTags =  [
    "text",
    "textPath"
],
SvgOnlyTagRx = new RegExp("^(" + SvgOnlyTags.join("|") + "$)")
console.log(SvgOnlyTagRx.test("textField")) // true!!!!!!

from surplus.

adamhaile avatar adamhaile commented on August 20, 2024

Pushed fix.

The reason for the RX over an array search is both performance and expressive power. I don't care nearly as much about performance in the preprocessor as I do in the runtime and generated code, but using an RX here is O(tag length) vs an array search which is O(tag length * # of SVG tags). V8's regex implementation is pretty darn fast.

from surplus.

ismail-codar avatar ismail-codar commented on August 20, 2024

Good

from surplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.