Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39906

Re: I don't get it

From The Natural Philosopher <tnp@invalid.invalid>
Newsgroups comp.lang.javascript
Subject Re: I don't get it
Date 2021-04-12 11:20 +0100
Organization A little, after lunch
Message-ID <s516tu$ptl$1@dont-email.me> (permalink)
References (10 earlier) <8735vytcwa.fsf@bsb.me.uk> <s4sn1v$5vl$1@dont-email.me> <87lf9qrozz.fsf@bsb.me.uk> <s4ujou$r1a$1@dont-email.me> <875z0tq723.fsf@bsb.me.uk>

Show all headers | View raw


On 11/04/2021 14:33, Ben Bacarisse wrote:
> The Natural Philosopher <tnp@invalid.invalid> writes:
> 
>> On 10/04/2021 19:08, Ben Bacarisse wrote:
>>> The Natural Philosopher <tnp@invalid.invalid> writes:
>>>
>>>> On 10/04/2021 15:47, Ben Bacarisse wrote:
>>>>> The Natural Philosopher <tnp@invalid.invalid> writes:
>>>>>
>>>>>> On 09/04/2021 20:01, John G Harris wrote:
>>>>>>> On Fri, 9 Apr 2021 10:03:13 +0100, The Natural Philosopher
>>>>>>> <tnp@invalid.invalid> wrote:
>>>>>>>
>>>>>>>       <snip>
>>>>>>>> After spending two days some years ago I discovered that IE and Firefox
>>>>>>>> differed in their handling of comparisons of numerical and string data,
>>>>>>>> and that something like
>>>>>>>>
>>>>>>>> if('1'== 1)
>>>>>>>>
>>>>>>>> was handled differently in each browser.
>>>>>>>>
>>>>>>>> As with all loosely typed languages, bugs in your code are trumped by
>>>>>>>> bugs in the language itself.
>>>>>>>
>>>>>>> Was that before or after they claimed to conform to ECMA 262? If
>>>>>>> after, one or both browsers had a bug, not the language. If before,
>>>>>>> that's what you get with USPs.
>>>>>>
>>>>>> It was around 2007 give or take. IE6 and XP was current. I coded for
>>>>>> firefox, it broke in IE6.
>>>>>>
>>>>>> I actually checked the language spec. As far as I cam remember the
>>>>>> spec was explicit, that you converted to whatever the target of an
>>>>>> assignement was in a mixed type operation, but in a conditional there
>>>>>> was no assignment type...
>>>>>
>>>>> So you looked in the wrong place.  I don't think that adds much useful
>>>>> information.  ECMA 262, 3rd edition (2000) is very clear about the
>>>>> conversions required by the == operator (section 11.9.1 and 11.9.3).
>>>>> For the record, the string should be converted to a number (and the
>>>>> algorithm for doing that is given in great detail too).
>>>>>
>>>>> So it's not an issue with the specification.  Testing in IE6 running on
>>>>> XP I find that the conversion is done correctly.  Did Mozilla really
>>>>> have such a crude bug, and if so, did you really code for that despite
>>>>> the specification being clear?
>>>>>
>>>> All I know is that IE6 and firefox gave different results and it was
>>>> down to an implicit cast in a conditional statement. The code I have
>>>> now - dated 2008, after fixing -  simply turns everything explicitly
>>>> into a Number()....so I assume that firefox was doing that implicitly
>>>> and IE6 was not.
>>>
>>> I've tested it on IE6.  Unless IE6 is a Heisenberg browser, it does the
>>> conversion correctly.
>>>
>>>> You can defend the language all you like - I was past caring.
>>>
>>> I'm not defending the language.
>>>
>>>> I had a job to do and IE6 and firefox produced completely different
>>>> results on the same web page, because of casting. Forcing everything
>>>> to a number whether it needed it or not fixed the issue.
>>>
>>> Maybe is was Mozilla that got it wrong, or maybe you are
>>> mis-remembering?
>>>
>> There was no right or wrong as I recall. Two browsers interpreted the
>> spec differently because the correct interpretation was not clear.
> 
> I don't think you have read the specification.  I can't see any room for
> misinterpretation in this case.  You made it clear that you had
> originally read the wrong part of the specification so you can hardly
> claim to be a reliable source for what the specification says.
> 
>> I coded for Mozilla. It worked, Others tried IE6, it didn't work. I
>> scattered explicit Number() casts throughout my code, it worked for
>> everyone.
> 
> Then you mislead people with your example, because IE6 does not get that
> conversion wrong.  I can't be sure that Mozilla did not (but I would be
> very surprised) but IE6 is readily available for testing.
> 
>> At some level mozilla was casting to a number,
> 
> In the case you cited, that is correct (and very clearly required by the
> specification).
> 
>> but IE6 wasn't.
> 
> I tested it on IE6 and it correctly converted the string to a number in
> the comparison.  I think you are spreading confusion.
> 
>> I spent a little time trying to work out what SHOULD happen, but the
>> spec didn't cover the exact case.
> 
> That is not true.  I gave you the section numbers that explain the
> required conversions in an equality comparison (the case you cited).


  I believe this the modified code snippet that worked - without the 
Number casts it differed on the two browsers

// turn off all menus at this level or higher, but turn on one at
// this level that matches id

function showmenu(level,id)
	{
	var allmenus;
	var exp=/PARENT/;
	var i;
	allmenus=document.getElementsByTagName('DIV');
	for (i=0; i<allmenus.length;i++)
		{
		var sample=allmenus[i];
		if (exp.test(sample.id)) // Its a menu div, which we want..
			{
			if (sample.style.zIndex >= level) // all levels at our level or above
				{
// this is the bad comparison
				if (Number(sample.id.slice(6))==Number(id)) // matches required expander
					{
					sample.style.display='block';
					document.getElementById('mousetray').style.display='block'; // turn 
on the mousetray
					}
				else sample.style.display='none';
				}
			}
		}
	}


-- 
"I guess a rattlesnake ain't risponsible fer bein' a rattlesnake, but ah 
puts mah heel on um jess the same if'n I catches him around mah chillun".

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 03:32 -0700
  Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 03:37 -0700
    Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 04:26 -0700
      Re: I don't get it JJ <jj4public@gmail.com> - 2021-04-08 19:39 +0700
        Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 05:53 -0700
          Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-08 13:55 -0700
            Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 00:46 -0700
              Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-09 10:03 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 04:09 -0700
                Re: I don't get it "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-04-09 11:07 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 03:23 +0100
                Re: I don't get it "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-04-10 22:02 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-11 01:05 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-11 01:07 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-11 11:42 +0100
                Re: I don't get it John G Harris <niam@jghnorth.org.uk.invalid> - 2021-04-09 20:01 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 13:31 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 03:37 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-09 23:53 -0700
                Re: I don't get it John G Harris <niam@jghnorth.org.uk.invalid> - 2021-04-10 12:05 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 15:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 15:47 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-10 18:25 +0100
                Re: I don't get it Jon Ribbens <jon+usenet@unequivocal.eu> - 2021-04-10 17:29 +0000
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-10 19:08 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-11 11:41 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-11 14:33 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-12 02:39 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-12 11:21 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-12 10:19 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-12 21:20 +0100
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-12 14:32 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 04:11 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-13 14:58 +0100
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:20 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:29 -0700
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-13 20:06 +0100
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-13 15:09 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-14 01:15 -0700
                Re: I don't get it "sc...@sauyet.com" <scott@sauyet.com> - 2021-04-14 05:22 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 11:52 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 11:57 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-15 12:04 -0700
                Re: I don't get it Scott Sauyet <scott.sauyet@gmail.com> - 2021-04-15 19:29 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 14:12 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 14:47 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-20 23:35 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:08 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:24 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-21 01:29 -0700
                Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-13 09:32 -0700
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-13 21:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 01:32 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 09:08 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 10:06 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 10:59 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 14:05 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-14 16:32 +0100
                Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-14 23:53 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-15 13:56 +0100
                Re: I don't get it The Natural Philosopher <tnp@invalid.invalid> - 2021-04-12 11:20 +0100
        Re: I don't get it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-08 15:21 +0100
          Re: I don't get it Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-04-09 16:50 +0200
  Re: I don't get it Man From a city with name Viljandi <he12457@hotmail.com> - 2021-04-08 10:44 -0700
  Re: I don't get it Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-04-10 00:01 -0700

csiph-web