我想观察htmlelement的“联系”属性。但是,由于它是只读的属性,其中没有属性列表。因此,覆盖Getter和Setter或创建代理对象的经典方法将没有用。
我已经阅读了MutationObserver,他们只能观察到属性。对于我们的应用程序,它们也很重,因为我们需要在我们创建的每个动态元素上观察此property(ISSECTECT)(80%的应用程序只是动态元素)。
还有其他方法可以观察到可读性属性的变化吗?
I wanted to observe "isConnected" property of an HTMLElement. But since it's a read-only property no propertyDiscriptor exists on it. So the classic approach of overriding getter and setter or creating a proxy object won't be useful.
I have read on mutationObserver, that they can only observe attributes. They are also heavy for our application as we need to observe this propperty(isConnected) on every dynamic element that we create ( 80% of the application is just dynamic elements).
Is there any other way to observe changes to readonly properties?
发布评论
评论(1)
OP应给出
mutation> mutation> mutation observer
尝试。对于OP的情况,节点的无法直接观察属性,但是相同的信息...节点属于或不是渲染dom的一部分...可以从'child -list'
突变类型中检索。 。The OP should give
MutationObserver
a try. For the OP's case a node'sisConnected
attribute can not be directly observed but the same information ... node either is or is not part of the rendered DOM ... can be retrieved from a'childList'
mutation type ...