19. 1998 Vector Markup Language proposed
by Macromedia, Microsoft. PGML
proposed by Adobe, Sun. W3C kick off
SVG.
2001 SVG 1.0
2003 SVG 1.1
2004 Konqueror 3.2 support
2005 Gecko (Firefox) support
2006 WebKit (Chrome, Safari) support
2011 IE9 is the last platform to support SVG
25. Setting SVG attributes
• Attributes are case sensitive
1 var div = document.createElement("div");
2 div.setAttribute("someWacky", "foo");
3 div.getAttribute("someWacky"); // => "foo"
4 div.getAttribute("somewacky"); // => "foo"
5
6 var svg = document.createElementNS(svgNS, "svg");
7 svg.setAttribute("someWow", "boo")
8 svg.getAttribute("someWow"); // => "boo"
9 svg.getAttribute("somewow"); // => null
• Property values are not primitives
1 svg.viewBox; // => SVGAnimatedRect {animVal: SVGRect, baseVal: SVGRect}
2 var viewBox = new SVGAnimatedRect(); // => TypeError: Illegal constructor
3 svg.viewBox = "0 0 100 100";
4 svg.getAttribute("viewBox"); // => null
26. Changing namespaces
1 <div>
2 <span></span>
3 <svg>
4 <path></path>
5 <foreignObject>
6 <div></div>
7 </foreignObject>
8 </svg>
9 </div>
Entrance to namespace dictated by next element
Exit from namespace dictated by previous element
39. Ember.js 1.8-1.9
1 var
2
3 buffer
4 parsingNode
5 parsingNode.innerHTML
6 var
7
8 if (isShowing) {
9 buffer
10 parsingNode.innerHTML
11
12 while (innerChildren[
13 outerChilden[
14 }
15 }
16
17 while (outerChilden[
18 rootElement.appendChild(outerChilden[
19 }
STRING TEMPLATES, DOM for stitching
40. Tricky stuff in 1.8+
• managing a context
• detecting a namespace
!
41. Tricky stuff in 1.8+
1 var string = handlebarsTemplate(context, options);
2 var nodes = domHelper.parseHTML(string, morph.contextualElement);
3
4 var node;
5 while (node = nodes[0]) {
6 rootElement.appendChild(node);
7 }
42. HTMLBARS, Tricky stuff in 1.8+
1.10
1 var nodes = htmlbarsTemplate(context, env, morph.contextualElement);
2
3 var node;
4 while (node = nodes[0]) {
5 rootElement.appendChild(node);
6 }
43. Tricky stuff in 1.8+
• managing a context
• detecting a namespace
!
44. Tricky stuff in 1.8+
1 var root = document.createElement('div');
2
3 root.innerHTML = "<svg><foreignObject><div></div></foreignObject></svg>";
4
5 var svg = div.firstChild;
6 var foreignObject = svg.firstChild;
7 var div = foreignObject.firstChild;
8
9 svg.namespaceURI; // http://www.w3.org/2000/svg
10 foreignObject.namespaceURI; // http://www.w3.org/2000/svg
11 div.namespaceURI; // undefined
45. Tricky stuff in 1.8+
1 var root = document.createElementNS(svgNs, 'svg');!
2 !
3 root.innerHTML = "<foreignObject><div></div></foreignObject>";!
4 !
5 var foreignObject = root.firstChild;!
6 var div = foreignObject.firstChild;!
7 !
8 svg.namespaceURI; // http://www.w3.org/2000/svg!
9 foreignObject.namespaceURI; // http://www.w3.org/2000/svg!
10 div.namespaceURI; // undefined!
46. Tricky stuff in 1.8+ HTMLBARS, 1.10
1 var template = htmlbarsCompile(
2 "<foreignObject><div></div></foreignObject>"
3 );
4 // so long as contextualElement is an SVG tag...
5 var nodes = template(context, env, morph.contextualElement);
6
7 var foreignObject = nodes[0];
8 var div = foreignObject.firstChild;
9
10 foreignObject.namespaceURI; // http://www.w3.org/2000/svg
11 div.namespaceURI; // undefined