SCEditor icon indicating copy to clipboard operation
SCEditor copied to clipboard

Is there a way to use getters/setters in the code for bbcodeHandlers?

Open abetis opened this issue 6 years ago • 6 comments

There are many places where the code checks if a property is a variable or a function in order to use its properly (value or make a call to the function). Is there a way to use getters/setters for those cases?

I had to change allowedChildren to a function for my implementation, if was used only in one place, so it was very easy to add isFunction(allowedChildren) where needed, but now I see that I need to have a function for isInline as well and it's used in lots of places. Getters/setters would be very useful in that case...

abetis avatar Apr 09 '18 12:04 abetis

Yes from my perspective. @samclarke is the one with the authority to give your final answer, though.

brunoais avatar Apr 09 '18 12:04 brunoais

The question is how to do it

abetis avatar Apr 09 '18 12:04 abetis

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get ?

brunoais avatar Apr 09 '18 15:04 brunoais

I've tried that before posing that issue and it didn't work. There are versions of used JS interfaces that support that and those that do not.

abetis avatar Apr 09 '18 16:04 abetis

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty ?

brunoais avatar Apr 09 '18 17:04 brunoais

That's beyond my knowledge in JS... The first version was self explanatory and similar to other languages, I was hoping it was possible to use it, but it didn't work as it is. Maybe there is something in the environment that can be updated so we could use that syntax. Hope @samclarke can address that.

abetis avatar Apr 09 '18 19:04 abetis