Comments (5)
I think the only difference is when typenames is the empty string or entirely whitespace.
"".split(/^|\s+/) // []
"".split(/\s+/) // [""]
from d3-dispatch.
@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.
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.
I’m not planning on taking any action. Thank you for the question.
from d3-dispatch.
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)
- dispatch.once? HOT 1
- Don’t allow whitespace or periods in dispatch(types). HOT 1
- Strange behavior in Safari v9 HOT 2
- Example in docs uses the 3.x API HOT 3
- API Proposal HOT 1
- Compose submodule with ES6 HOT 1
- Register with bower. HOT 2
- Support for multiple callbacks HOT 2
- Rewrite without using closures. HOT 1
- Observable collection is empty HOT 2
- Don’t expose the dispatch.type. HOT 1
- Add dispatch.copy.
- dispatch.on(types, listener) should take multiple types.
- Fix prototype.constructor.
- Throw an error if the specified callback is not null and not a function. HOT 1
- Either fail gracefully or emit useful error message .on("unknownEvent") HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-dispatch.