Giter Club home page Giter Club logo

Comments (5)

mbostock avatar mbostock commented on April 30, 2024 1

I think the only difference is when typenames is the empty string or entirely whitespace.

"".split(/^|\s+/) // []
"".split(/\s+/) // [""]

from d3-dispatch.

ChALkeR avatar ChALkeR commented on April 30, 2024

@mbostock Ah, thanks, I totally missed that.

Perhaps that could be solved with .filter(function(t) { return t; }) instead?
Or, a length check after .trim().

from d3-dispatch.

ChALkeR avatar ChALkeR commented on April 30, 2024

I'm not even sure though that this would make things work under Qt QML, I checked pretty long ago.
Perhaps that needs a recheck before anything is done here.

from d3-dispatch.

mbostock avatar mbostock commented on April 30, 2024

I’m not planning on taking any action. Thank you for the question.

from d3-dispatch.

localpcguy avatar localpcguy commented on April 30, 2024

I think I've found a (browser?) bug related to this regex and the question asked by @ChALkeR here. In Internet Explorer (v11 is where I saw this), the regex /^|\s+/ splits a string into it's individual characters. So something like "end".trim().split(/^|\s+/) in IE11 outputs ["e", "n", "d"]. In modern browsers, it outputs [ "end" ] as expected.

The issues seems to be the pipe, it looks like it causes IE to split not on the whitespace but on nothing, effectively.

I'm not sure what the expected browser support is, but as suggested above, using .split(/\s+/).filter(function(t) { return t; }) would achieve the same result, work in IE9+ (when .filter was added), and eliminate the regex bug.

Let me know if this should be a new bug.

from d3-dispatch.

Related Issues (17)

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.