|
What am I missing here? In react I have an image with two events...code:
code:
|
# ? Dec 22, 2017 04:45 |
|
|
# ? May 16, 2024 08:56 |
|
huhu posted:What am I missing here? In react I have an image with two events... Does the hover cause any new element to be displayed? Sounds like maybe something is appearing on top of the element with the handlers attached so that mouse leave is immediately triggered.
|
# ? Dec 22, 2017 05:05 |
|
huhu posted:What am I missing here? In react I have an image with two events... I remember solving a similar problem by instantiating the events. code:
e- something like... code:
Nolgthorn fucked around with this message at 20:34 on Dec 22, 2017 |
# ? Dec 22, 2017 20:24 |
|
You will also have an issue using the second before it is declared. Functions are basically magically declared first, where if you are assigning things it does happen in order. code:
|
# ? Dec 22, 2017 21:16 |
|
I'm about to inherit a project that currently has little-to-no testing and as I'd like to fix that as I continue development. I'll likely be able to cover a lot of the cases with simple unit tests, but the project does have a lot of browser-based dependencies that I'd prefer to write additional functional tests for rather than constantly stubbing out the window. The current tests are a combination of tape and testling, but considering that the testling website has a big banner that says "Testling is currently not working. We're working to fix it!" it doesn't seem like this is the best path to continue down. Some reading has pointed me in the direction of Mocha/Webdriver.io (since the Selenium interface is attractive), but I don't know if I'm just setting myself up with subpar tools or not. The code itself will be extremely primitive JavaScript (no Promises, async, etc.) Any advice or guidance would be appreciated.
|
# ? Dec 23, 2017 01:39 |
|
Shrimpy posted:I'm about to inherit a project that currently has little-to-no testing and as I'd like to fix that as I continue development. I'll likely be able to cover a lot of the cases with simple unit tests, but the project does have a lot of browser-based dependencies that I'd prefer to write additional functional tests for rather than constantly stubbing out the window. Ideally, you would decouple as much logic as possible from the actual DOM, so you can test all of that without any idea it's a web page.
|
# ? Dec 23, 2017 02:11 |
|
Skandranon posted:Ideally, you would decouple as much logic as possible from the actual DOM, so you can test all of that without any idea it's a web page. That's my intention, though part of this will require DOM manipulation and checking browser compatibility, so I'm kind of stuck using a browser or something browser-like at some point in the process.
|
# ? Dec 23, 2017 02:22 |
|
Shrimpy posted:That's my intention, though part of this will require DOM manipulation and checking browser compatibility, so I'm kind of stuck using a browser or something browser-like at some point in the process. Testing in multiple browsers is typically slow and also difficult. How many legacy browsers are you supporting? I'd suggest having them run on Jenkins. But, blah. Really I'd rather figure out what parts of the code are browser-sensitive and fix them.
|
# ? Dec 23, 2017 05:30 |
|
Dogcow posted:Does the hover cause any new element to be displayed? Sounds like maybe something is appearing on top of the element with the handlers attached so that mouse leave is immediately triggered. This was it, thanks! Another question, any best practice tips for dealing with Adjacent JSX elements returning from a function? Wrapping it in a div tag feels a little smelly. Or, for example for a ternary operator, wrapping both returns in the parent tag feels a bit the opposite of DRY.
|
# ? Dec 23, 2017 22:18 |
|
huhu posted:This was it, thanks! If you are using 16+ you can render/ return arrays: code:
|
# ? Dec 23, 2017 23:58 |
|
Lumpy posted:If you are using 16+ you can render/ return arrays: Using React.Fragment with 16.2.x is much simpler for most cases. code:
|
# ? Dec 24, 2017 09:33 |
|
Shrimpy posted:That's my intention, though part of this will require DOM manipulation and checking browser compatibility, so I'm kind of stuck using a browser or something browser-like at some point in the process. Perhaps Selenium/Nightwatch for the DOM stuff?
|
# ? Dec 24, 2017 12:47 |
|
Roadie posted:Using React.Fragment with 16.2.x is much simpler for most cases. How is that simpler than the Array?
|
# ? Dec 24, 2017 18:23 |
|
necrotic posted:How is that simpler than the Array? No comma separator between each element, declarative, easier to copy and paste elsewhere.
|
# ? Dec 24, 2017 19:24 |
|
Can you push to a frament variable and return that later? I'd prefer the consistency of array usage if not.
|
# ? Dec 24, 2017 19:37 |
|
code:
EDIT: As in, either use bind everywhere or don't use 'this.method'.
|
# ? Dec 24, 2017 19:55 |
|
theLamer posted:
The purpose of bind is to keep current scope when function fires. If a mouse event handler fires, the scope will ordinarily be the document unless you bind it - so this seems to be the classical use of ".bind(this)".
|
# ? Dec 24, 2017 21:20 |
|
And assigning it like that before use is better for React. Binding in render would look like a new function to the virtual DOM.
|
# ? Dec 24, 2017 22:01 |
|
It's better to bind a function than it is to create a new function on every execution. Especially in React especially on event declarations. React has a couple of failings in this way, Vue you don't have to do bindings like that.
|
# ? Dec 25, 2017 21:16 |
|
I prefer that React requires you do be explicit on your function bindings.
|
# ? Dec 25, 2017 21:47 |
|
This is a completely stupid little thing that isn't really even an issue (no one has ever fixed it in over a decade) but it's bugging the absolute poo poo out of me, and I can't code. I ran Microsoft's tracelog.exe for the Win7 WDK. Then I created a html report with the tracerpt.exe utility. The HTML that this creates uses old lovely 10 year old Microsoft Javascript that was designed for IE8/9. It still displays on modern browsers, but the STUPID LITTLE THING that is bugging me is the image icon toggles don't work. In other words, when you click the "+" node (which is actually open.gif): ...it's supposed to use close.gif to change it to "-" when opened. But it doesn't work (even on IE8/9). It does open, but still displays open.gif: The Javascript that should handle this looks like this: code:
The <img> tags look like this: code:
Does anyone know how to fix it? Here's the whole HTML in context: https://tommycatkins.com/2017/tracelogs/tracelog_shape_host.html https://tommycatkins.com/2017/tracelogs/
|
# ? Dec 26, 2017 05:32 |
|
Maldoror posted:ARGH I HATE JAVASCRIPT! When I stepped through in Chrome, i.nodeName displayed as "IMG", so maybe you need to allow for both? IE: if (i.nodeName === "img" || i.nodeName === "IMG") {
|
# ? Dec 26, 2017 06:00 |
|
Maldoror posted:This is a completely stupid little thing that isn't really even an issue (no one has ever fixed it in over a decade) but it's bugging the absolute poo poo out of me, and I can't code.
|
# ? Dec 26, 2017 06:05 |
|
Skandranon posted:When I stepped through in Chrome, i.nodeName displayed as "IMG", so maybe you need to allow for both? IE: if (i.nodeName === "img" || i.nodeName === "IMG") { That makes it so that it displays a broken image for "altImage", and the broken image has properties as "undefined": The same effect is achieved with only if (i.nodeName == "IMG") and doing a search and replace on the entire html of "<img" to "<IMG"
|
# ? Dec 26, 2017 07:08 |
|
mystes posted:I don't think you can access custom attributes using object property syntax, so you probably need to change i.altImage to use getattribute and setattribute. I repeat, I can't code. So I'm afraid I have to be a fool and ask, "How do I do that?"
|
# ? Dec 26, 2017 07:11 |
|
Maldoror posted:That makes it so that it displays a broken image for "altImage", and the broken image has properties as "undefined": Well, part of your problem is the code that is supposed to do the swap isn't being run when you click the icon. So you probably want it to do SOMETHING, the problem is now the code inside that IF block. I would suspect how it is supposed to swap out the src is no longer valid. mystes is probably right, you can't grab altImage like it is doing, so when that section DOES run, it's getting undefined. Since you know for that section it should always be close.gif and open.gif, maybe you can just hardcode those for now? Skandranon fucked around with this message at 08:19 on Dec 26, 2017 |
# ? Dec 26, 2017 08:14 |
|
Part of the problem may be that the original gifs were linked as "res://wdc.dll/contents.gif". This only works in IE. And, it seems to behave the same whether the images are linked as actual images, or as that wdc.dll bullshit. In other words, changing if (i.nodeName == "IMG") to if (i.nodeName == "img") has the exact same problem behavior with the gifs linked as "res://wdc.dll/blah.gif". I can see on this technet blog that this dude ran this back in January 2012 (in Win7/IE9 I'm guessing) and seems to have correctly working output. It could be that this Microsoft Shitcode only works properly on IE9.
|
# ? Dec 26, 2017 08:33 |
|
Maldoror posted:I repeat, I can't code. So I'm afraid I have to be a fool and ask, "How do I do that?" Change: code:
code:
|
# ? Dec 26, 2017 13:16 |
|
It works! Thank you so much dude.
|
# ? Dec 26, 2017 15:36 |
|
I'm interested in capturing and parsing incoming email. For the time being I'm using a 3rd party service but it would be really nice if I could just very simply receive and parse email myself. With a DNS MX record set up, how difficult is it in a node app to capture an email? Once I have captured the email, is it difficult to take it apart? I found this module, which may do what I want however it doesn't talk about how to get the email to begin with. https://github.com/nodemailer/mailparser
|
# ? Jan 2, 2018 14:26 |
|
The same authors offer a SMTP server implementation. oops https://nodemailer.com/extras/smtp-server/
|
# ? Jan 2, 2018 14:47 |
|
I have a 2D array of objects that I'm trying to compress as much as possible into a URI component string that I can use as a query string on a URL. Given the height and width, it has a lot of elements, and I don't know how much further I can go realistically. My 2D array setup: code:
code:
|
# ? Jan 9, 2018 04:58 |
|
Don't use JSON, you'll probably want a custom format you encode/decode to. If speed isn't a concern you could go two step: transform the hashes to arrays with keys mapping to fixed indexes. JSON + LZMA might work for you then.
|
# ? Jan 9, 2018 05:31 |
LP0 ON FIRE posted:Any ideas on how to compress it even more? zlib seems to compress it to ~200-300 characters (after encoding it to Base64) https://jsfiddle.net/tpkn3fsg/ lunar detritus fucked around with this message at 05:50 on Jan 9, 2018 |
|
# ? Jan 9, 2018 05:45 |
|
LP0 ON FIRE posted:I have a 2D array of objects that I'm trying to compress as much as possible into a URI component string that I can use as a query string on a URL. Given the height and width, it has a lot of elements, and I don't know how much further I can go realistically. Might be the long way around but use an array buffer (tree.buffer) and convert that into a string, then you may get better compression from your lz library. https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String https://developers.google.com/web/updates/2014/08/Easier-ArrayBuffer-String-conversion-with-the-Encoding-API Lemon King fucked around with this message at 07:19 on Jan 9, 2018 |
# ? Jan 9, 2018 07:13 |
|
LP0 ON FIRE posted:Any ideas on how to compress it even more? Use buffer, set up each field as an unsigned int of appropriate length, get a string from the buffer, and compress that. JavaScript code:
|
# ? Jan 9, 2018 09:26 |
|
Wow thank you for the responses. I'm sure all of these would be helpful. And here I was thinking I was maybe hopeless. Even that 200-300 characters is impressive.
|
# ? Jan 9, 2018 14:43 |
|
Has anyone done Wes Bos's Node course by chance? Any thoughts?
|
# ? Jan 12, 2018 22:17 |
|
Murrah posted:Has anyone done Wes Bos's Node course by chance? Any thoughts? No, but there is a sale on udemy right now and they have node courses
|
# ? Jan 13, 2018 00:22 |
|
|
# ? May 16, 2024 08:56 |
|
It seems like Udemy always has a sale on. I'm currently going through this course on Node.js. I'm about halfway through, and so far it's been a bit of ES6, and a lot of npm packages that does different kinds of stuff. I'm not entirely sure it's any good, so maybe shop around for some other stuff? I don't feel like I've gotten a lot out of it, but it was like USD 12 so I don't think I've been robbed. It's like 25 hours worth of stuff. What I would have probably tried to get, had I known a little more than I did when I purchased it, I would have looked for something that went a bit deeper in less different stuff. Right now it feels like I've just been shown a lot of tools, and how they apply in one specific instance.f
|
# ? Jan 13, 2018 00:41 |