New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error at this line return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim(); #4547
Comments
How are you using |
I'm using moment.js with jQuery in an asp.net application where I'm calculating monthly payments, my code:
javascript does not have a trim function, so I edited the moment.js file to remove the .trim on line 2280. My code had been running just fine with no errors when all of a sudden I was getting this error. I had added moment.js to my project, Visual Studios 2013, via NuGet. This code was developed about a month ago and right up until my message had been running just fine. I uninstalled the NuGet packge and downloaded the moment.js file from GitHub and edited the line. Everything works as expected now. I just posted the code that I was executing, there's additional code for weekly intervals and bi-weekly intervals. So some variables set earlier in the code arer missing here. I was testing the payment process (end to end) with a monthly payment when the error occurred. |
@chartierpw The line using You say you installed moment via NuGet, it's used in an ASP.NET application, and it was running just fine. It seems likely that you (or someone else) has updated the NuGet packages, run the application on an older platform (with an older JS runtime), or, you've only just encountered a situation where you're using/parsing RFC2822 dates. What O/S are you running this application on? |
Wow ... not running on Windows 7 in IE v11. I add the .trim() back in the moment.js and the script fails, take it out and it runs.. I literally ran the code just fine on one run and then the very next run, 10 seconds later, it failed. I had made no changes to my javascript (jQuery) code, only a procedural change in the process I was testing. I use Visual Studios 2013 v12.0.40629.00 Update 5, JQuery JavaScript Library v1.11.2. The code fails on this line in my code: totalmonths = moment(paymentbydate).diff(startdate, 'month') + 1; paymentbydate = "07/23/2018" Still fails this morning, line 2280 in moment.js, with the error: 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'trim' So if trim() was added in 2009, and this line in moment.js 9 months ago, why is it now suddenly failing? |
See MSDN
Perhaps something else is triggering the page to render in quirks mode instead of standards. You might be able to check this according to stackoverflow doing: javascript:window.alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode.') (Checking if IE is in one of the backwards compatible standards modes is a bit more complicated - you might try another stackoverflow answer or maybe follow more MSDN info for Compatibility View) |
Added that line of code and it reports that I am in Standards mode .... |
Do you see the Compatibility View icon in the address bar? Can you add |
I'm not using the Edge browser, I'm using IE 11 .... I didn't think to test it with Chrome or Firefox, so I did. It fails only with IE v11 11.0.49 (KB4052978), set to update automatically ... strange .... Setting compatibility mode for localhost did nothing ... still fails at the same line .... seems like the problem is with IE 11. Haven't tested with Edge yet, my development environment is on Windows 7, so Edge isn't available. I'll try Edge from my Windows 10 machine later ... I any event, I still cannot use moment.js with the trim() on line 2280 as IE 11 is still widely used ... |
Just so you know, the error occurs whether I'm in comparability mode or not. IE 11 v11 11.0.49 (KB4052978) apparently has an issue which will never be fixed by Microsoft as, as far as I know, they have discontinued updates. Correct me if I'm wrong .... |
I'm not sure about MS approach to updates for IE11. They still seem to push out the occasional random patch (e.g. KB4089187 published a month ago.) However... moment docs (still) claim to support IE 8, which definitely doesn't have I've raised PR #4564 to remove it again. |
Thanks for you help ... I tried to test using Edge, but Windows 10 is such a POS, I cannot type anything into the Edge address bar and so far I haven't been able to fix that, so testing with Edge is not going to happen soon, I just don't have time to mess with Windows 10, did I say what a POS Windows 10 is, oh ... yeah .... I did .... :) |
All of a sudden, today, after using moment.js for about a month I now get an error, every time, at line# 2280, return s.replace(/([^)]*)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();, in the moment.js file, I receive the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'trim'
Why, all of a sudden, am I getting this?
The text was updated successfully, but these errors were encountered: