javascript - polymer/深度/选择器在移动设备中不起作用

标签 javascript html css-selectors polymer shadow-dom

当设备屏幕大小调整时,我尝试重新排列布局,所以我这样做:

if(screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) {
        document.querySelector("html /deep/ [landscape-horizontal]").removeAttribute('vertical');
        document.querySelector("html /deep/ [landscape-horizontal]").setAttribute('horizontal', '');
}

这在桌面计算机上正常工作,但在移动设备(Android 手机、平板电脑和 iOS 模拟器)中我收到此错误:

"Uncaught SyntaxError: Failed to execute 'webkitMatchesSelector' on 'Element': 'html /deep/ [landscape-horizontal]' is not a valid selector.", source: bower_components/platform/platform.js (0)

有什么想法吗? 谢谢!

最佳答案

目前有一个open issue在 Shadow DOM polyfill 中支持这一点。它适用于 Chrome 35+,因为它使用 native Shadow dom。

关于javascript - polymer/深度/选择器在移动设备中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24858786/

相关文章:

php - 有什么解决方案可以在 laravel Blade 上操作 MySQL 数据库中包含的超链接吗?

excel - 如何通过 Selenium VBA 向某些 HTML 元素发送文本?

javascript - 将使用 $.get() 呈现的部分 View 中的任何数据传递到 ContentPage

JavaScript 函数不会在 html 文件上输出任何内容

html - Firefox 中的布局困惑 - 列?

css - 有人可以解释一下这个复杂的 css 的作用吗

ruby - 在 Nokogiri CSS 选择器中指定图像宽度和/或高度的范围

javascript - 悬停和连接端点 jsPlumb 的问题

twig 资源中的 Javascript 变量

带有 AJAX 调用的 php 变量范围