metal / metal.js

Build UI components in a solid, flexible way
http://metaljs.com
Other
229 stars 59 forks source link

Add the warning that the `domData.get` functionality with the `set` functionality will be deprecated in the major release #364

Open matuzalemsteles opened 6 years ago

matuzalemsteles commented 6 years ago

Hey guys,

Since domData.set has been added and the domData.get functionality has been set to set so that we do not have a breaking change, it would be important to add warnings that the next major release will depreciate this feature.

Something like:

static get(element, name, initialValue) {
    if (!element[METAL_DATA]) {
        element[METAL_DATA] = {};
    }
    if (!name) {
        return element[METAL_DATA];
    }
    if (!isDef(element[METAL_DATA][name]) && isDef(initialValue)) 
        console.warn('domData: get with the set functionality will be deprecated and removed in the next major releases.');
        element[METAL_DATA][name] = initialValue;
    }
    return element[METAL_DATA][name];
}

What do you think?

diegonvs commented 6 years ago

I think that we can try use this transform https://www.npmjs.com/package/babel-plugin-log-deprecated, what do you think?

matuzalemsteles commented 6 years ago

Hey @diegonvs how we talk it off, being a library no longer maintained maybe not ideal and covers few use cases. In this case it's just showing a warning when you use the set functionality insideget.

I do not think we need to try to automate this, just show a friendly message to the developer 🙂.