<commit_before>import { registry } from './registry.js';
import { isString } from './typeof.js';

function isNew(node) {
    try {
        return !isString(node.outerHTML);
    } catch (ex) {
        return true;
    }
}

export function Polyfill(Original) {
    const Modified = function() {
        if (this.constructor) {
            if (!isNew(this)) {
                return this;
            }
            let desc = registry.get(this.is);
            let config = desc.config;
            // Find the tagname of the constructor and create a new element with it
            let element = document.createElement(
                config.extends ? config.extends : this.is
            );
            if (config.extends) {
                element.setAttribute('is', this.is);
            }
            element.__proto__ = desc.Ctr.prototype;
            return element;
        }
        return null;
    };
    Modified.prototype = Object.create(Original.prototype, {
        constructor: {
            value: self[name],
            configurable: true,<commit_msg>fix: crossbrowser shim for native elements<commit_after>import { registry } from './registry.js';
import { isString } from './typeof.js';

function isNew(node) {
    try {
        return !isString(node.outerHTML);
    } catch (ex) {
        return true;
    }
}

export function Polyfill(Original) {
    function Modified() {
        if (this.constructor) {
            if (!isNew(this)) {
                return this;
            }
            let desc = registry.get(this.is);
            let config = desc.config;
            // Find the tagname of the constructor and create a new element with it
            let element;
            if (registry.native) {
                element = Reflect.construct(
                    Original,
                    [],
                    this.constructor
                );
            } else {
                element = document.createElement(
                    config.extends ? config.extends : this.is
                );
            }
            element.__proto__ = desc.Ctr.prototype;
            if (config.extends) {
                element.setAttribute('is', this.is);
            }
            return element;
        }
        return null;
    }
    Modified.prototype = Object.create(Original.prototype, {
        constructor: {
            value: Modified,
            configurable: true,
{'fraction_non_alphanumeric': 0.09991708126036485, 'fraction_numerical': 0.0, 'mean_word_length': 1.4522357723577235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5961534', 'n_tokens_mistral': 616, 'n_tokens_neox': 602, 'n_words': 153}