我有一些 NPM 具有使用 jQuery 对 SVG 元素进行选择的依赖项。下面是我的 NPM 使用 jQuery 进行 SVG 选择时收到的警告。
'SVGElement.offsetWidth' 已弃用,将于 2016 年 4 月左右在 M50 中删除。有关更多详细信息,请参阅https://www.chromestatus.com/features/5724912467574784。locuslabs.js:6635 'SVGElement.offsetHeight' 已弃用,将于 2016 年 4 月左右在 M50 中删除。有关更多详细信息,请参阅https://www.chromestatus.com/features/5724912467574784。
Chrome 提出了以下建议:
“这些属性应该只在 HTMLElement 上受支持,但在 WebKit 和 Blink 中的所有元素上都受支持。getBoundingClientRect() 通常可以用作替代品。” -philipj@opera.com
这是创建此特定警告的 jQuery 代码部分。
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
var valueIsBorderBox = true,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
...
问题:
NPM 是否提供了一种方法来修改 NPM 用作依赖项的 jQuery 版本?这是解决这个问题的最佳方法,还是我应该以不同的方式解决这个问题?澄清一下,这不是一个技术问题,而是一个最佳实施问题。