D
David Mark
The user is supposed to click on it. If the mouse moves during that
click, the text will, by default, be selected.
When the user tries to select text in a link or button, text selection
does not occur.
You can normally select the text in a link.
Those browsers are much more rare than the problems caused by
inexperienced scripters using javascript:.
Certainly, but it is best to avoid - in - when possible. I definitely
wouldn't use it with host objects.
For most applications, these browsers are not worth testing in. The
Certainly not. I can't even get IE4 to run on XP. I wouldn't install
NN4.
amount of trouble required to get anything to work would not be worth
it. There is no 'user-select' and a majority of the CSS would fail, as
would getElementById.
Well, you would test gEBI and skip the enhancement if it is not
present. This is preferable to failure due to an unknown operator.
The - in - operator is generally safe to use.
Yes, generally.
You've made the assertion that - in - should not be used (because it
doesn't work in NS 4), and especially not on a Host object.
I agree that using it on a host object is a bad idea.
I've already covered the NS4 argument.
You suggested that typeof should be used. Did you think that typeof
*must* be safe to use on a host object? Always?
It has shown to be the safest method for testing properties of host
objects.
The typeof operator can return anything on a Host object. I showed this
Correct.
to be true in my last post where typeof document.body.style.filter is
undefined in Webkit, even though it is a string value. You've shown no
example.
And that is a good thing. The typeof test works just as it should.
An - in - test would fail.
In the case where an object might have a property that might be a
string, the value could potentially be the value - undefined -.
And is in practice, as you have shown. The Safari developers likely
did this on purpose and it is good that they did. Why they would
spoof the filter property at all is another question.
In that case, we could use typeof:-
if(typeof el.unselectable != "undefined") {
}
would be true, even if el had an unselectable property.
In this case, you would check for a boolean. True enough, some mad
browser developer(s) could return 'xyz', but there is no reason to
bank on such bizarre behavior. The only known typeof oddity is
"unknown" by MS, which indicates properties of ActiveX objects (at
least that is the prevailing theory.) Those throw exceptions on type
conversion, but none of the known offenders are booleans.
You're misinterpreting what I wrote.
The _value_ for the unselectable property would have no be not undefined.
Why? If I add an expando called "unselectable" that is undefined,
will it be - in - the element? Hard to say with host objects, but it
seems logical that it would.
I did not write that the result of using typeof el.unselectable would
have to be not "undefined".
It would need to be something other than that to take it seriously.
The result of typeof el.unselectable should probably be "string",
however, detecting if the property exists is sufficient enough.
Why would it be a string?
Since Safari does not implement Microsoft filters at all, we see the result
of a wise design decision by Apple and WebKit contributors here.
Feature-testing code would then not use the branch for Microsoft filters.Fair enough. Where have you feature-tested that property in your example?[...]
The previous line:-
if('unselectable' in el)
el.unselectable = 'on'
- is a feature check.And an inherently error-prone at that.
It is no more error prone than using the native typeof operator.
I don't agree.
[snip]