Why does document.createTextNode() not allow setAttribute()?
<p>So while working with the dom, I came across the situation where I assumed that the object resulting from <code>document.createTextNode()</code> would be treated in a similar way to an object resulting from <code>document.createElement();</code>, in that I would be able to call <code>setAttribute()</code> on it.</p>

<p>Example:</p>

<pre><code>var genericElementNode = document.createElement('p');
genericElementNode.setAttribute('id', 'sampleId1');
// The above will run fine


var textNode = document.createTextNode("Hello World");
textNode.setAttribute('id', 'sampleId2');
//The above will result in an error:
//Uncaught TypeError: textNode.setAttribute is not a function
</code></pre>

<p>Why is this the case? And are there any workarounds?</p>