From: Garrett Smith on
David Mark wrote:
> I have posted a new primer related to host objects and feature
> detection/testing.
>
> http://www.cinsoft.net/host.html
>

| The isHostObjectProperty function tests if the specified host object
| property references an object that is safe to evaluate.

The term "evaluate" is non-standard terminology. What do you mean?

[snip comments about John Resig]
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: David Mark on
Garrett Smith wrote:
> Thomas 'PointedEars' Lahn wrote:
>> David Mark wrote:
>>
>>> I have posted a new primer related to host objects and feature
>>> detection/testing.
>
> [...]
>
>>
>> ISTM the RegExp is borken:
>>
>> var reFeaturedMethod = new RegExp('^function|object$', 'i');
>>
>> It matches case-insensitive either "function" at the begin of input or
>> "object" at the end, when it should match case-insensitive an input
>> that is either "function" or "object":
>>
>> var reFeaturedMethod = new RegExp('^(function|object)$', 'i');
>>
>
> A Literal would be shorter and would stay cached:
>
> /^(?:func|obj)/;

I fail to see how that is the same thing, but the non-capturing bit is a
good idea.

As for caching, I don't see how it makes any difference as I create the
RegExp object once.

>
>> Furthermore, AISB,
>>
>> return !!((reFeaturedMethod.test(t) && o[m]) || t == 'unknown');
>>
>> becomes more efficient when writing
>>
>> return !!(t == 'unknown' || (reFeaturedMethod.test(t) && o[m]));
>>
>> The double negation to cast to boolean is a matter of taste; I do not
>> think it is necessary, because one possible result is a boolean
>> already and the other has been proven by this that it can be used in a
>> type-converting test.
>>
> Double negation on a boolean is pointless. However, `o[m]` should not be
> a boolean; it should be a function or an object.

Right.

>
> Caveats:
> Object `o` could be callable and falsish, such as nonstandard callable
> "document.all".
>
> Object `o` could be the `item` method, for which typeof will result
> "string" in IE. This would result in isHostMethod returning false.

Yes, I should add both of those stipulations to the docs and this example.
From: David Mark on
Garrett Smith wrote:
> David Mark wrote:
>> I have posted a new primer related to host objects and feature
>> detection/testing.
>>
>> http://www.cinsoft.net/host.html
>>
>
> | The isHostObjectProperty function tests if the specified host object
> | property references an object that is safe to evaluate.
>
> The term "evaluate" is non-standard terminology. What do you mean?

Anything along the lines of type conversion, assigning a reference to a
variable, etc. What would you call it?
From: kangax on
On 3/23/10 12:52 PM, David Mark wrote:
> I have posted a new primer related to host objects and feature
> detection/testing.
>
> http://www.cinsoft.net/host.html

Is there a reason `isHostObjectProperty` is not called `isHostProperty`
(to be consistent with `isHostMethod`)?

Also, `findProperietaryStyle` doesn't include "Ms" prefix. Why?
(<http://blogs.msdn.com/ie/archive/2008/09/08/microsoft-css-vendor-extensions.aspx>)

Finally, it might be worth mentioning that `isEventSupported` could (and
_does_, as any other inference) return false positives; from those I
know about � `window`'s "error" in Chrome (present but "defunct"), and
"contextmenu" in Opera 10.50 (even when corresponding option is off in
settings!).

[...]

--
kangax
From: David Mark on
kangax wrote:
> On 3/23/10 12:52 PM, David Mark wrote:
>> I have posted a new primer related to host objects and feature
>> detection/testing.
>>
>> http://www.cinsoft.net/host.html
>
> Is there a reason `isHostObjectProperty` is not called `isHostProperty`
> (to be consistent with `isHostMethod`)?

The "Object" goes with "Property", not the "Host" part.

>
> Also, `findProperietaryStyle` doesn't include "Ms" prefix. Why?
> (<http://blogs.msdn.com/ie/archive/2008/09/08/microsoft-css-vendor-extensions.aspx>)

Happenstance. It was written before IE8 came out and the sorts of
things I've used it for have had only non-CSS equivalents (e.g. opacity,
transform). I'll add it as they do have a handful of proprietary CSS3
implementations that could be useful to detect (e.g. text-overflow). I
thought I had since added MS for that one in particular, but it may have
been on some other project (I hastily copied the posted implementation
from a My Library add-on).

>
>
> Finally, it might be worth mentioning that `isEventSupported` could (and
> _does_, as any other inference) return false positives; from those I
> know about � `window`'s "error" in Chrome (present but "defunct"), and
> "contextmenu" in Opera 10.50 (even when corresponding option is off in
> settings!).

It is only meant to be used with elements (which I should stipulate of
course). As for "contextmenu", I never considered that a false
positive. The event is supported, but like many things in browsers, the
user has the ability to get in the way. But from your wording, it
sounds as if there is a bug in Opera 10.5 that should be noted (and
reported).

Thanks for the input!