Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to extend Custom Elements #175

Open
maikelmclauflin opened this issue Jul 13, 2017 · 1 comment
Open

Unable to extend Custom Elements #175

maikelmclauflin opened this issue Jul 13, 2017 · 1 comment

Comments

@maikelmclauflin
Copy link

maikelmclauflin commented Jul 13, 2017

basic code is as follows

    var Constructors = {};
    var api = {
        register: register,
        extend: extend,
        core: extendCore,
        content: extendContent,
        Constructors: Constructors
    };
    fn(api);
    return api;

    function extendCore(name, obj) {
        return extend('core', name, obj);
    }

    function extendContent(name, obj) {
        return extend('content', name, obj);
    }

    function extend(from, to, obj_) {
        var obj = obj_ || {};
        obj.extends = prefix(from);
        obj.prototype = Constructors[from].prototype;
        return register(to, obj);
    }

    function register(name, obj) {
        var constructor = xtag.register(prefix(name), obj);
        Constructors[name] = constructor;
        return constructor;
    }

    function forOwn(obj, fn) {
        return Object.keys(obj).forEach(function (key) {
            fn(obj[key], key, obj);
        });
    }

    function prefix(name) {
        return 'skit-' + name;
    }
}(xtag, Promise, function (skit) {
    skit.register('core', {
        lifecycle: {
            created: function (e) {
                console.log('here');
            },
            removed: function () {},
            inserted: function () {},
            attributeChanged: function () {}
        },
        methods: {
            // open ended
        },
        events: {
            // open ended
        }
    });
    skit.core('content', {
        lifecycle: {
            created: function () {
                console.log('there');
            },
            removed: function () {},
            inserted: function () {},
            attributeChanged: function () {}
        },
        methods: {
            // open ended
        },
        events: {
            // open ended
        }
    });
}));```

errors on second call then console log here is called 2x
@csuwildcat
Copy link
Member

This is much, much easier and reliable in v2 - landing imminent on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants