简体   繁体   English

Angular SVG单元测试如何获取SVGLengthList

[英]Angular SVG Unit tests how get SVGLengthList

Hello I have a question about SVG. 您好,我对SVG有疑问。 I write unit test and i must add to method object with type SVGLengthList . 我编写单元测试,并且我必须添加类型为SVGLengthList方法对象。 I read W3 and i don't know how can get this object. 我读了W3 ,但我不知道如何获得该对象。 I try do operation about DOM, where have a 3 svg elements, but I can only get object type equal SVGLength 我尝试对具有3个svg元素的DOM进行操作,但是我只能获得等于SVGLength对象类型

var $document = $injector.get("$document");
svgParent = $document.find('svg')[0];
svgLength = $document[1].createSVGLength();

and my DOM: 和我的DOM:

        var virtualDOM = [
        '<html>',
            '<body>',
                '<svg>',
                    ic_dialog_info,
                    ic_edit,
                '</svg>',
                ic_down,
            '</body>',
        '</html>'
    ].join("");

where ic_dialog_info, ic_edit, ic_down it's a svg icon. 其中ic_dialog_info,ic_edit,ic_down是svg图标。

I found solution how create SVGLengthList, I created element tspan with Namespace " http://www.w3.org/2000/svg ". 我找到了如何创建SVGLengthList的解决方案,并使用命名空间“ http://www.w3.org/2000/svg ”创建了元素tspan。 next I use property 'x' where 'x' is SVGAnimatedLengthList, and I take baseVal) that's all :) very simple :) 接下来,我使用属性“ x”,其中“ x”是SVGAnimatedLengthList,我使用baseVal),这很简单:)

svgLengthList = document.createElementNS('http://www.w3.org/2000/svg', 'tspan').x.baseVal; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM