matthewp / haunted

React's Hooks API implemented for web components 👻

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.textContent and .innerHTML support

mikabytes opened this issue · comments

commented

https://codepen.io/mikabytes/pen/oNjQQNE (open inspector and check console)

Currently, Haunted elements try to set these native properties using Reflect.set

            set(target, key, value, receiver) {
                let desc;
                if (key in target) {
                    desc = Object.getOwnPropertyDescriptor(target, key);
                    if (desc && desc.set) {
                        desc.set.call(receiver, value);
                        return true;
                    }
                    Reflect.set(target, key, value);   // <---------------------- HERE
                }
                if (typeof key === 'symbol' || key[0] === '_') {
                    desc = {
                        enumerable: true,
                        configurable: true,
                        writable: true,
                        value
                    };
                }

This causes a TypeError: Illegal invocation error. I'm not sure why.

Probably we could solve this by using target[key] = value instead of Reflect.

commented

I'd be happy to take a stab at this if you want?

commented

Just ran accross this while using className as well.