Nicolai Schmid
Nicolai Schmid

Reputation: 1092

Polymer 2.0 Class heredy protected properties

I'm tying to create a classMixin in Polymer which provides custom methods and will be inherited by other elements.

Everything is working as expected, but I want to inherit some properties as well.

static get properties() {
    return {
        // Make this protected
        test: {
            value: 'test',
        }
    };
}

How would I make this test property protected, so it can be used by the inheriting class?

Upvotes: 1

Views: 153

Answers (2)

Schrodinger's cat
Schrodinger's cat

Reputation: 1102

Just add an underscore when you declare it

    static get properties() {
    return {
        // Make this protected
        _test: {
            value: 'test',
        }
    };
}

Refer here

Upvotes: 2

enno.void
enno.void

Reputation: 6579

So there are no visibility modifiers like protected in JavaScript. To use these properties in different classes just create another mixin that declares the properties.

Upvotes: 0

Related Questions