MDL在动态网站上降级 [英] MDL on dynamic websites downgrading

查看:123
本文介绍了MDL在动态网站上降级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个适用于MDL的旧的基于ajax的GUI。
整个页面内容是动态构建的(来自xml描述)。

We have a old large ajax based GUI adapted to MDL. The whole page content is build dynamically (from xml description).

componentHandler.downgradeElements( /all old notes/ ;
remove all old notes form DOM
add new page content to DOM
componentHandler.upgradeAllRegistered();

这样可以正常工作,但是如果组件 MaterialLayout 是动态创建的,它会泄漏内存。
使用降级修复程序(#2009删除了内部引用。

内存泄漏的原因是组件 MaterialLayout 将一个监听器添加到MediaQueryList(MDL 1.1)。

This works fine, but it leaks memory if the component MaterialLayout is alos created dynamically . With the "downgrading fix (#2009" the internal references are removed.
The reason for the memory leak is that the component MaterialLayout adds a listener to the MediaQueryList (MDL 1.1).

 this.screenSizeMediaQuery_.addListener(this.screenSizeHandler_.bind(this));

在MDL 1.1.2中,添加了两个Windows事件处理程序,导致同样的问题。

In MDL 1.1.2 there are two windows event handler added which lead to the same problem.

window.addEventListener('pageshow', function (e) { ... } );
...
window.addEventListener('resize', windowResizeHandler);

downgradeElements 不会删除此侦听器。因此DOM元素不是GC。

This listeners are not removed by downgradeElements. And therefore the DOM elements are not GC.

问题:


  • 是吗没有缩进以删除元素 MaterialLayout

  • 我在这里做的完全错了吗?

  • 这是MDL问题吗?

  • 是否有解决方法而不更改MDL代码?

  • Is it not indented to delete the element with MaterialLayout?
  • Is it completely wrong what I doing here?
  • Is this an MDL issue?
  • Is there a workaround without changing MDL code?

推荐答案

MDL有一个问题报告布局降级#1340

There was a issue report for MDL Layout downgrade #1340

最终结论是:

MDL适用于1.x的无状态站点。在布局组件的初始构建期间,不会破坏整个布局。

所以正确答案是:

不缩进使用MaterialLayout for MDL 1.x删除元素。

其他信息:

For一个hack解决(测试)我删除了从material.js添加MediaQueryList监听器(仍然是1.0.4,deconstructComponentInternal形式1.1.2)。这似乎适用于我们的解决方案。到目前为止,我没有发现任何缺点(在我们的解决方案中)。

Additional information:
For a hack work around (for testing) I removed adding the MediaQueryList listener from material.js (still 1.0.4 with deconstructComponentInternal form 1.1.2). This seems to work for our solution. I did not found any drawbacks (again in our solution) up to now.

这篇关于MDL在动态网站上降级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆