From 7b6a3c452fc6f588c59b82298a8fc1ac3ed85773 Mon Sep 17 00:00:00 2001 From: milahu Date: Mon, 14 Sep 2020 15:51:18 +0200 Subject: [PATCH] hide internal props --- lib/CSSStyleDeclaration.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js index bded9a44..e05588f3 100644 --- a/lib/CSSStyleDeclaration.js +++ b/lib/CSSStyleDeclaration.js @@ -14,15 +14,13 @@ var getBasicPropertyDescriptor = require('./utils/getBasicPropertyDescriptor'); * @constructor * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration */ +const D = Object.defineProperty; var CSSStyleDeclaration = function CSSStyleDeclaration(onChangeCallback) { - this._values = {}; - this._importants = {}; - this._length = 0; - this._onChange = - onChangeCallback || - function() { - return; - }; + // hidden props + D(this, '_values', {value: {}, writable: true}); + D(this, '_importants', {value: {}, writable: true}); + D(this, '_length', {value: 0, writable: true}); + D(this, '_onChange', {value: (onChangeCallback || function(){}), writable: true}); }; CSSStyleDeclaration.prototype = { constructor: CSSStyleDeclaration, @@ -56,8 +54,8 @@ CSSStyleDeclaration.prototype = { this.removeProperty(name); return; } - var isCustomProperty = name.indexOf('--') === 0; - if (isCustomProperty) { + if (name.slice(0, 2) == '--') { + // custom property this._setProperty(name, value, priority); return; }