<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Prototype: &#8220;element-id&#8221;.$() instead of $(&#8217;element-id&#8217;)</title>
	<atom:link href="http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<pubDate>Sun, 20 Jul 2008 23:40:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Dr Nic</title>
		<link>http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/#comment-260</link>
		<dc:creator>Dr Nic</dc:creator>
		<pubDate>Tue, 12 Sep 2006 11:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/#comment-260</guid>
		<description>Yeah, I'm glad I was using Firefox so I could see the error. On the Spin-off forum I think they said they might patch the original $() code so that it does more thorough testing of the arguments.

e.g argument instanceof String &#124;&#124; argument.constructor(String)

Then the method in the article should just be able to call $(this) in Firefox as well.</description>
		<content:encoded><![CDATA[<p>Yeah, I&#8217;m glad I was using Firefox so I could see the error. On the Spin-off forum I think they said they might patch the original $() code so that it does more thorough testing of the arguments.</p>
<p>e.g argument instanceof String || argument.constructor(String)</p>
<p>Then the method in the article should just be able to call $(this) in Firefox as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Revinsky</title>
		<link>http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/#comment-259</link>
		<dc:creator>Andrew Revinsky</dc:creator>
		<pubDate>Tue, 12 Sep 2006 11:17:19 +0000</pubDate>
		<guid isPermaLink="false">http://drnicwilliams.com/2006/09/11/prototype-call-dollar-on-string/#comment-259</guid>
		<description>Hi everyone!

The "this" in your latter example refers to an inner implementation of a string in a String object. 

In IE, the "this" is of "object" type, not "string". The logic of $() function, as you know, first checks whether the argument is a string (by typeof'ing it) and if not, it returns this same object assuming (in our case, wrongly) it's a DOM element.

Now, in IE, it turns out, an inner string is still a string in essence (when viewed in debugger it isn't split unto characters or anything..). But in FireFox although "this" is still of "object" type, it also supports indexing (as seen by Firebug), giving access to individual constituent characters of the string.

Back to what you had, since String.prototype.$ (and "this" not being a strictly of "string" type) at the end returns the inner String's object, its output depents on inner String's object implementation in browsers.

Dr. Nic, you probably used FireFox for your tests.

Thank you!</description>
		<content:encoded><![CDATA[<p>Hi everyone!</p>
<p>The &#8220;this&#8221; in your latter example refers to an inner implementation of a string in a String object. </p>
<p>In IE, the &#8220;this&#8221; is of &#8220;object&#8221; type, not &#8220;string&#8221;. The logic of $() function, as you know, first checks whether the argument is a string (by typeof&#8217;ing it) and if not, it returns this same object assuming (in our case, wrongly) it&#8217;s a DOM element.</p>
<p>Now, in IE, it turns out, an inner string is still a string in essence (when viewed in debugger it isn&#8217;t split unto characters or anything..). But in FireFox although &#8220;this&#8221; is still of &#8220;object&#8221; type, it also supports indexing (as seen by Firebug), giving access to individual constituent characters of the string.</p>
<p>Back to what you had, since String.prototype.$ (and &#8220;this&#8221; not being a strictly of &#8220;string&#8221; type) at the end returns the inner String&#8217;s object, its output depents on inner String&#8217;s object implementation in browsers.</p>
<p>Dr. Nic, you probably used FireFox for your tests.</p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
