From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> Garrett Smith wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Garrett Smith wrote:
>>>> Thomas 'PointedEars' Lahn wrote:
>>>>> Garrett Smith wrote:
>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>> return String(this).replace(/^\s+|\s+$/g, "");
[...]
>>>>> Host objects SHOULD NOT be augmented with properties, or be used as
>>>>> first argument to Function.prototype.call() or
>>>>> Function.prototype.apply(). Your argument is not logical.
>>> did you not get?
>> I understand and agree. However, it is reasonable to allow for an object
>> to be the first argument to `trim`.
>
> What the heck are you talking about? String.prototype.trim() takes no
> arguments per ES5!
>
Right. I meant the `this` argument.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Thomas 'PointedEars' Lahn on
Garrett Smith wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Garrett Smith wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> Garrett Smith wrote:
>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>> Garrett Smith wrote:
>>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>>> return String(this).replace(/^\s+|\s+$/g, "");
> [...]
>>>>>> Host objects SHOULD NOT be augmented with properties, or be used as
>>>>>> first argument to Function.prototype.call() or
>>>>>> Function.prototype.apply(). Your argument is not logical.
>>>> did you not get?
>>> I understand and agree. However, it is reasonable to allow for an
>>> object to be the first argument to `trim`.
>>
>> What the heck are you talking about? String.prototype.trim() takes no
>> arguments per ES5!
>
> Right. I meant the `this` argument.

And as I already pointed out above, it is _not_ reasonable for that to
refer to a host object. Anyhow, if it refers to an object, that object
must have or inherit a toString() or valueOf() method, or a TypeError
exception must be thrown.

So as Asen pointed out, the user-defined implementation in the FAQ works
differently than the standards-compliant implementation of the method, when
the goal was to provide a fallback in case the standards-compliant
implementation of the method was not available. Now where is the logic in
that?


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
From: Dr J R Stockton on
In comp.lang.javascript message <hpmad2$bdl$1(a)news.eternal-
september.org>, Thu, 8 Apr 2010 21:28:15, Garrett Smith
<dhtmlkitchen(a)gmail.com> posted:
>
>>> Why not just put "For example, MSIE 8 does not match ..." and maybe add
>>> the version of the script engine. Currently I have JScript 5.8.22960.
>>>
>> OK. That is more specific; sounds like an improvement. I'll add and
>>update the FAQ with that.
>
>On second thought, mentioning IE8 potentially misleading because it is
>incomplete. Safari 2 and Konqueror also do not match no-break space.
>The chart in the article from that entry has test results of what is
>and what is not matched in various browsers.
>http://perfectionkills.com/whitespace-deviations/


The "For example" accommodates that, for the literate.

In general, ISTM that the FAQ should consider IE6 & possibly earlier,
because IE comes with Windows and some Web users upgrade nothing. But
those who have chosen to install non-IE in a PC are much more likely to
update it at least occasionally. Normal usage of Safari 2 should by
now be insignificant.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> Garrett Smith wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Garrett Smith wrote:
>>>> Thomas 'PointedEars' Lahn wrote:
>>>>> Garrett Smith wrote:
>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>> Garrett Smith wrote:
>>>>>>>> Thomas 'PointedEars' Lahn wrote:
>>>>>>>>> return String(this).replace(/^\s+|\s+$/g, "");

[...]
> So as Asen pointed out, the user-defined implementation in the FAQ works
> differently than the standards-compliant implementation of the method, when
> the goal was to provide a fallback in case the standards-compliant
> implementation of the method was not available. Now where is the logic in
> that?
So we should be throwing TypeError for that case.

I can't say I like that much, but if it is what is required by the
specification, and this method is a fallback, then it should follow that.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/