<commit_before>
module.exports =

    add: (parent, el) ->
        $el = el._jquery
        $par = parent._jquery
        if parent is parent.builder
            i = $par.length - 1
            $par = $par.add($el)
            if parent._browser.wrapped # FIXME
                $par.first().replaceWith($el)
                if parent.parent is parent.parent?.builder # FIXME recursive?
                    $parpar = parent.parent?._jquery
                    parent._browser.wrapped = no
                    $par = $par.not(':first') # rm placeholder span
                    $parpar?.splice($parpar.index($par), i+1, $par...)
            else if $par.parent().length > 0
                $el.insertAfter($par[i])
        else
            $par.append($el)
        # $.add isnt inplace
        parent._jquery = $par

    replace: (oldtag, newtag) ->
        parent = newtag.parent
        $new = newtag._jquery
        $old = oldtag._jquery
        $par = parent._jquery

        if parent is parent.builder
            $par.splice($par.index($old), $old.length, $new...)

        if $old.parent().length > 0
            $old.replaceWith($new)
        # $.replaceWith isnt inplace
        newtag._jquery = $new

    text: (el, text) ->
        el._jquery.text(text)

    raw: (el, html) ->
        el._jquery.html(html)

    attr: (el, key, value) ->
        if value is undefined
            el._jquery.removeAttr(key)
        else
            el._jquery.attr(key, value)

    show: (el) ->
        el._jquery.show()

    hide: (el) ->
        el._jquery.hide()

    remove: (el, opts) ->
        if opts.soft
            el._jquery.detach()
        else
            el._jquery.remove()
<commit_msg>remove elements from parent<commit_after>
module.exports =

    add: (parent, el) ->
        $el = el._jquery
        $par = parent._jquery
        if parent is parent.builder
            i = $par.length - 1
            $par = $par.add($el)
            if parent._browser.wrapped # FIXME
                $par.first().replaceWith($el)
                if parent.parent is parent.parent?.builder # FIXME recursive?
                    $parpar = parent.parent?._jquery
                    parent._browser.wrapped = no
                    $par = $par.not(':first') # rm placeholder span
                    $parpar?.splice($parpar.index($par), i+1, $par...)
            else if $par.parent().length > 0
                $el.insertAfter($par[i])
        else
            $par.append($el)
        # $.add isnt inplace
        parent._jquery = $par

    replace: (oldtag, newtag) ->
        parent = newtag.parent
        $new = newtag._jquery
        $old = oldtag._jquery
        $par = parent._jquery

        if parent is parent.builder
            $par.splice($par.index($old), $old.length, $new...)

        if $old.parent().length > 0
            $old.replaceWith($new)
        # $.replaceWith isnt inplace
        newtag._jquery = $new

    text: (el, text) ->
        el._jquery.text(text)

    raw: (el, html) ->
        el._jquery.html(html)

    attr: (el, key, value) ->
        if value is undefined
            el._jquery.removeAttr(key)
        else
            el._jquery.attr(key, value)

    show: (el) ->
        el._jquery.show()

    hide: (el) ->
        el._jquery.hide()

    remove: (el, opts) ->
        if opts.soft
            el._jquery.detach()
        else
            el._jquery.remove()
            parent = el.parent
            $par = parent._jquery
            $el = el._jquery
            if parent is parent.builder
                $par.splice($par.index($el), $el.length)

{'fraction_non_alphanumeric': 0.13135240211052485, 'fraction_numerical': 0.0022216051096917524, 'mean_word_length': 1.4436906377204886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3655693', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1041, 'n_words': 241}