polymer - 无法访问 WCT 中 Shadow Root 内的元素
问题描述
在我的单元测试中,我无法从影子根访问 dom 元素。
var el = fixture('basic');
var imgElement = el.shadowRoot.querySelector('img');
我在 imgElement 中得到空值。如何获取 img 元素?我也试过,
var imgElement2= document.querySelector('img');
解决方案
您必须先使用该setup
功能
suite('test', function(){
setup(function () {
my-el = fixture('DefaultElement');
});
推荐阅读
- swift - 由于 .onDelete 调整系统总计
- javascript - 按数组内容过滤/选择 javascript 对象
- angular - TSLint 无参考规则替代方案
- c++ - 使用 ATMega328p-au 和 Atmel Studio 时出现 PWM 输出错误
- gpu - GPU 编程(非 CUDA)和面向对象设计
- node.js - 角度不会向节点js rest API发出发布请求
- mouse - QB64 _MOUSEMOVEMENT 未读取任何输入
- typescript - 如何从本地机器上传一些文件?
- embedded - PIC16F18876 UART 配置失败
- terraform - 嵌套列表中的 Terraform 嵌套循环