<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eli Grey &#187; DOM</title>
	<atom:link href="http://eligrey.com/blog/post/tag/dom/feed" rel="self" type="application/rss+xml" />
	<link>http://eligrey.com/blog</link>
	<description>this instanceof Whitty</description>
	<lastBuildDate>Sat, 24 Dec 2011 22:58:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Another E4X DOM library</title>
		<link>http://eligrey.com/blog/post/another-e4x-dom-library</link>
		<comments>http://eligrey.com/blog/post/another-e4x-dom-library#comments</comments>
		<pubDate>Sun, 22 Nov 2009 16:10:26 +0000</pubDate>
		<dc:creator>Eli</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[E4X]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JavaScript Libraries]]></category>

		<guid isPermaLink="false">http://eligrey.com/blog/?p=390</guid>
		<description><![CDATA[I just made another E4X DOM library, but this one is intended to implement the optional features in the ECMA-357 standard that are not implemented by Mozilla in JavaScript. The library is named e4x.js due to, for the most part, it only implementing stuff already specified in E4X. The only difference between the standard and [...]]]></description>
			<content:encoded><![CDATA[<p>I just made another E4X DOM library, but this one is intended to implement the optional features in the ECMA-357 standard that are not implemented by Mozilla in JavaScript. The library is named <a href="http://github.com/eligrey/e4x.js">e4x.js</a> due to, for the most part, it only implementing stuff already specified in E4X. The only difference between the standard and my implementation is that the <code>XML.xpath(xpathExpression)</code> method also supports numeric, string, and boolean result types.</p>
]]></content:encoded>
			<wfw:commentRss>http://eligrey.com/blog/post/another-e4x-dom-library/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>E4X DOM toolkit</title>
		<link>http://eligrey.com/blog/post/e4x-dom-toolkit</link>
		<comments>http://eligrey.com/blog/post/e4x-dom-toolkit#comments</comments>
		<pubDate>Sun, 27 Sep 2009 19:36:11 +0000</pubDate>
		<dc:creator>Eli</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[E4X]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JavaScript Libraries]]></category>
		<category><![CDATA[JavaScript Snippets]]></category>

		<guid isPermaLink="false">http://eligrey.com/blog/?p=387</guid>
		<description><![CDATA[I have created a small JavaScript toolkit named e4x-dom.js for making it easy to manipulate the DOM with E4X. The following methods are implemented on XML objects by e4x-dom.js: node() Returns the HTML node representation of the XML. over(element or selector) Either overwrites element or every element matched by the CSS selector with node(). overId(id) [...]]]></description>
			<content:encoded><![CDATA[<p>I have created a small JavaScript toolkit named <a href="http://purl.eligrey.com/e4x-dom">e4x-dom.js</a> for making it easy to manipulate the DOM with E4X.</p>
<p>The following methods are implemented on XML objects by e4x-dom.js:</p>
<dl>
<dt><code>node()</code></dt>
<dd>Returns the HTML node representation of the XML.</dd>
<dt><code>over(element or selector)</code></dt>
<dd>Either overwrites <code>element</code> or every element matched by the CSS selector with <code>node()</code>.</dd>
<dt><code>overId(id)</code></dt>
<dd>Same as <code>over(document.getElementById(id))</code> but also preserves the the id of the element being overwritten in the element replacing it.</dd>
<dt><code>fill(element or selector)</code></dt>
<dd>Removes every child node of <code>element</code> or every element matched by the CSS selector. Then <code>node()</code> is appended to all of the emptied elements.</dd>
<dt><code>fillId(id)</code></dt>
<dd>Same as <code>fill(document.getElementById(id))</code></dd>
<dt><code>appendTo(element or selector)</code></dt>
<dd>Appends <code>node()</code> to <code>element</code> or every element matched by the CSS selector.</dd>
<dt><code>appendToId(id)</code></dt>
<dd>Same as <code>appendTo(document.getElementById(id))</code>.</dd>
<dt><code>insertBefore(element or selector)</code></dt>
<dd>Inserts <code>node()</code> before <code>element</code> or every element matched by the CSS selector.</dd>
<dt><code>insertBeforeId(id)</code></dt>
<dd>Same as <code>insertBefore(document.getElementById(id))</code>.</dd>
<dt><code>insertAfter(element or selector)</code></dt>
<dd>Inserts <code>node()</code> after <code>element</code> or every element matched by the CSS selector.</dd>
<dt><code>insertAfterId(id)</code></dt>
<dd>Same as <code>insertAfter(document.getElementById(id))</code>.</dd>
</dl>
<p>The following are examples of using the toolkit:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> img <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;</span>img
 src<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Enter an image URI&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
 alt<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Describe the image&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
 id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;foobar&quot;</span>
<span style="color: #339933;">/&gt;;</span>
img.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>h1<span style="color: #339933;">&gt;</span>The image was <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>removed<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span>.<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span>.<span style="color: #660066;">overId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foobar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>And then <span style="color: #000066; font-weight: bold;">this</span> text node filled the header<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>.<span style="color: #660066;">fill</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#foobar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// the CDATA isn't itself put into the document but the data inside it is escaped so it</span>
<span style="color: #006600; font-style: italic;">// works in HTML and XHTML</span>
<span style="color: #339933;">&lt;</span>h1<span style="color: #339933;">&gt;&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span><span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">in</span> here <span style="color: #000066; font-weight: bold;">is</span> <span style="color: #339933;">&lt;</span>escaped<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;&lt;/</span>h1<span style="color: #339933;">&gt;</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">firstChild</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// if you just want to create an element quickly, do xml.node()</span>
<span style="color: #339933;">&lt;</span>svg xmlns<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.w3.org/2000/svg&quot;</span> viewBox<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;0 0 100 100&quot;</span><span style="color: #339933;">/&gt;</span>.<span style="color: #660066;">node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// SVG node</span>
<span style="color: #339933;">&lt;</span>div<span style="color: #339933;">/&gt;</span>.<span style="color: #660066;">node</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// div node</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// DOM methods are forwarded to .node()[method]()</span>
<span style="color: #339933;">&lt;</span>canvas<span style="color: #339933;">/&gt;</span>.<span style="color: #660066;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;2d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;</span>foo bar<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;baz&quot;</span><span style="color: #339933;">/&gt;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;baz&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// same as getting .@bar</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// mass-modifications with CSS selectors</span>
<span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span>Absolute links are <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>not<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;</span> allowed<span style="color: #339933;">&lt;/</span>strong<span style="color: #339933;">&gt;</span>
 .<span style="color: #660066;">over</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href^=&quot;http://&quot;], a[href^=&quot;https://&quot;], a[href^=&quot;//&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>user.<span style="color: #660066;">hasEditPrivileges</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #006600; font-style: italic;">// wikipedia-style &quot;put an edit link at the start of each section&quot;</span>
 <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;/edit?page=&quot;</span> <span style="color: #339933;">+</span> page.<span style="color: #660066;">id</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#91;</span>edit<span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'h2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// &lt;![CDATA[]]&gt; nodes directly accessed are converted to text nodes:</span>
&nbsp;
<span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
 <span style="color: #000066; font-weight: bold;">This</span> <span style="color: #000066; font-weight: bold;">is</span> a text node.
 <span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">is</span> escaped inside it.
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#some-element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://eligrey.com/blog/post/e4x-dom-toolkit/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

