Dynamic config for node spec attribute

Hello. I wonder that The node spec is possible to config on creation? I couldn’t find related specific example.

Here is my Span node spec example.

const spanSpec = {
    inline: true,
    group: "inline",
    atom:true,
    attrs:{
        class : {default:'default_class'}
    }
}

I want to config the Atom attribute by the class attribute something like this.

const spanSpec = {
    inline: true,
    group: "inline",
    atom: function(){
        if( this.attrs.class.indexOf('default_class')!==-1 ){
            return true;
        }else{
            return false;
        }
    },
    attrs:{
        class : {default:'default_class'}
    }
}

Is there any other easy or appropriate ways of this? Or I should update that Atom attrs after creation? (I think I may miss something.) Any advice would be appreciated.

No, this isn’t possible—the node spec is expected to be a stable, immutable thing. Definitely don’t update them after creation either. Maybe you could create different node types for the atomic and non-atomic variants of the node?

Thanks for your quick reply. I will make another spec for this.