I want to convert Mike Herchel's Importing CSS Breakpoints into ES6 class. For this, I chose to use get
and set
to finally learn how to.
My code so far:
export default class Breakpoints {
constructor() {
this.value = null;
this.refreshValue();
window.addEventListener('resize', () => {
this.refreshValue();
});
}
refreshValue() {
let val = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content').replace(/\"/g, '');
this.value = val;
}
set value(val) {
this.value = val;
}
get value() {
return this.value;
}
}
Problem is, when I run it, I am getting Maximum call stack size exceeded
. Where I did go wrong?