From fde60e3a5eec8e7db8a5497e88bfb223ffe4dbca Mon Sep 17 00:00:00 2001 From: dhrname Date: Mon, 6 May 2013 19:53:56 +0900 Subject: [PATCH] =?utf8?q?SVGForeignElement=E3=81=AE=E5=AE=9F=E8=A3=85?= =?utf8?q?=E9=96=8B=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- org/w3c/dom/svg.js | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/org/w3c/dom/svg.js b/org/w3c/dom/svg.js index c3bb08e..1354650 100644 --- a/org/w3c/dom/svg.js +++ b/org/w3c/dom/svg.js @@ -6291,14 +6291,15 @@ function SVGDefinitionSrcElement() { }; SVGDefinitionSrcElement.prototype = Object._create(SVGElement); -function SVGForeignObjectElement() /*: +function SVGForeignObjectElement(_doc) /*: SVGElement, SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, SVGTransformable, - events::EventTarget*/ { + events::EventTarget*/ { + this._tar = _doc.createElement("div"); SVGElement.apply(this); var sl = SVGAnimatedLength; /*readonly SVGAnimatedLength*/ this.x = new sl(); @@ -6306,6 +6307,37 @@ function SVGForeignObjectElement() /*: /*readonly SVGAnimatedLength*/ this.width = new sl(); /*readonly SVGAnimatedLength*/ this.height = new sl(); sl = void 0; + this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){ + if(evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) { + var tar = evt.target; + if ((evt.nodeType === /*Node.ELEMENT_NODE*/ 1) + && !tar._tar && tar.namespaceURI ==="http://www.w3.org/1999/xhtml") { + tar._tar = _doc.createElement(tar.localName); + } else if ((evt.nodeType === /*Node.TEXT_NODE*/ 3) && !tar._tar) { + tar._tar = _doc.createTextNode(tar.data); + } + var tnext = tar.nextSibling, + sar = tar._tar, + spar = tar.parentNode._tar, + snext = null; + if (sar && spar) { + if (!tnext) { + spar.appendChild(sar); + } else { + while(tnext) { + if (tnext._tar) { + /*use要素や実体参照は_tarプロパティをもっていないので、無視する*/ + snext = tnext.tar; + break; + } + tnext = tnext.nextSibling; + } + spar.insertBefore(sar, snext); + } + } + tnext = sar = spar = snext = void 0; + } + }, true); }; SVGForeignObjectElement.prototype = Object._create(SVGElement); -- 2.11.0