Browse files

Fix for bug #9 ("lexical" scope for ids)

  • Loading branch information...
1 parent 9bc2747 commit 8c2d51cd249145d5575f035b67e2bb6f798c184a julien@igel.co.jp committed Apr 7, 2012
Showing with 16 additions and 12 deletions.
  1. +0 −4 apps/ttfd.xml
  2. +8 −2 bender.js
  3. +7 −5 index.html
  4. +1 −1 tests/drag.xml
View
4 apps/ttfd.xml
@@ -229,10 +229,6 @@
<set use="p1" property="max-y">return value ? 100 : Infinity;</set>
<set use="p2" property="min-y">return value ? 0 : -Infinity;</set>
<set use="p2" property="max-y">return value ? 100 : Infinity;</set>
- <!--
- <set use="p1" property="y">return this.uses.p1.properties.y</set>
- <set use="p2" property="y">return this.uses.p2.properties.y</set>
- -->
</watch>
</app>
View
10 bender.js
@@ -203,6 +203,7 @@
{
this.component.ownerDocument._refreshed_instance(this);
this.unrender();
+ this.component.__instance = this;
if (flexo.root(this.use) !== this.use.ownerDocument) return;
if (this.use.__placeholder) {
this.target = this.use.__placeholder.parentNode;
@@ -241,8 +242,12 @@
this.render_children(ch, ch._find_target(dest));
}
} else if (ch.localName === "content") {
- this.render_children(this.use.childNodes.length > 0 ?
- this.use : ch, dest, ref);
+ if (this.use.childNodes.length > 0) {
+ var component = component_of(this.use);
+ component.__instance.render_children(this.use, dest, ref);
+ } else {
+ this.render_children(ch, dest, ref);
+ }
}
} else {
this.render_foreign(ch, dest, ref);
@@ -348,6 +353,7 @@
if (this.uses.$parent && this.uses.$parent.__pending_watches) {
this.uses.$parent.render_watches();
}
+ delete this.component.__instance;
},
unrender: function()
View
12 index.html
@@ -650,9 +650,9 @@
<li id="bug.8">Rendering vs. updating components (<a
href="lib/run.html?href=../tests/refresh-property.xml">test
case</a>)</li>
- <li id="bug.9">View <code class="attr">id</code>s as <code
- class="elem">content</code> inside <code class="elem">use</code>
- elements?</li>
+ <li id="bug.9" class="done">View <code class="attr">id</code>s as
+ <code class="elem">content</code> inside <code
+ class="elem">use</code> elements?</li>
<li id="bug.10" class="done">Placeholder nodes are not deleted.</li>
<li id="bug.11">Calculator: 1+2+3+= is 9, should be 6.</li>
</ol>
@@ -692,6 +692,8 @@
<li>Easier component sub-classing, including through markup.</li>
<li><code class="elem">template</code>/<code
class="elem">derive</code> elements to replace _clone_node</li>
+ <li>Restrict value ranges for properties (min/max, choice,
+ etc.)</li>
</ul>
</section>
@@ -843,8 +845,8 @@
<li><a class="broken"
href="lib/run.html?href=../tests/refresh-property.xml">Refresh
application after properties have changed</a></li>
- <li><a class="broken" href="lib/run.html?href=../tests/drag.xml">Drag
- component</a> (bug #9: id inside use)</li>
+ <li><a href="lib/run.html?href=../tests/drag.xml">Drag
+ component</a></li>
<li><a
href="lib/params.html?href=../tests/bezier.xml">Bézier
curve</a></li>
View
2 tests/drag.xml
@@ -3,7 +3,7 @@
<title>Drag component/id in content</title>
<view>
<svg:svg id="svg" viewBox="0 0 400 400">
- <use href="../lib/drag.xml" id="d">
+ <use href="drag.xml" id="d">
<svg:circle fill="#08f" id="c"/>
</use>
</svg:svg>

0 comments on commit 8c2d51c

Please sign in to comment.