How to create shallow copy of element?
<p>Recently in <a href="https://stackoverflow.com/questions/39220891/how-to-find-out-if-style-is-present-in-a-class-by-jquery/39298537#39298537">this question</a> I asked how to find out if style is present in a class. I was told (by skobaljic) that I need to clone element. During the call .clone() of the element (jQuery method) the resulting object contains default styles (e.g. from style sheet) so the inserted styles are not included in the clone. This is how I understood it. But it seems to be strange to clone complete element including all his childern elements which may be hunderets or thousands when I need to detect if 6 style are present. I cheched the jQuery's code for clone method. There is this:</p>

<pre><code>destElements = getAll( clone );
srcElements = getAll( elem );
</code></pre>

<p>So the function getAll is called twice.</p>

<p>Then I checked what contains getAll:</p>

<pre><code>var ret = typeof context.getElementsByTagName !== "undefined" ?
    context.getElementsByTagName( tag || "*" ) :
    typeof context.querySelectorAll !== "undefined" ?
    context.querySelectorAll( tag || "*" ) :
    [];
</code></pre>

<p>From Mozilla manual:</p>

<blockquote>
  <p>The Element.getElementsByTagName() method returns a live
  HTMLCollection of elements with the given tag name. The subtree
  underneath the specified element is searched, excluding the element
  itself.</p>
  
  <p>Document.querySelectorAll() - Returns a list of the elements within
  the document (using depth-first pre-order traversal of the document's
  nodes) that match the specified group of selectors. The object
  returned is a NodeList.</p>
</blockquote>

<p>So it is evident that creating deep copy of the element is pointless and it takes performance. This problem is yet intensified when I need to make deep search/comparison which would lead to excessive waste of resources. I would like to clone the element without it's children element. Is this possible? The clone should contain the default styles just like you do it with .clone(). How to do it?</p>