Check if specified element is inside selection
<p>I'm searching for cross browser solution (Chrome, FF, Opera > 10, IE >= 8) for the following problem:</p>

<p>There is some html code:</p>



<pre class="lang-html prettyprint-override"><code>&lt;div&gt;
    &lt;div id="one"&gt;
        &lt;p id="red"&gt;red&lt;/p&gt;
        &lt;p id="green"&gt;green&lt;/p&gt;
    &lt;/div&gt;
    &lt;div id="two"&gt;
        &lt;p id="blue"&gt;blue&lt;/p&gt;
        &lt;p id="black"&gt;black&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>and user selects with mouse text from 'een' (in #green node) to 'blu' (in #blue node). How can I check if #blue is inside selection (it does not matter if is whole or partially selected) and #red and #black are not in selection.
Simple API would look like this:</p>

<pre class="lang-js prettyprint-override"><code>Selection.isElementSelected(document.getElementById('black'));
</code></pre>

<p>I've tried to use DOMSelection and Ranges but the problem is that I need to check elements in nested structure. In Chrome I can use Range.intersectsNode(), but this is the only browser with support of this method.</p>

<p>Any suggestions?</p>
