Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for #2531093 #25

Closed
wants to merge 2 commits into from

4 participants

andreas.karlsson Eric Ferraiuolo Satyen Desai Ryan Grove
andreas.karlsson

Made _uiAddChild always append the child's bb to the parent node which fixes #2531093
Added a test for the issue.

Eric Ferraiuolo
Owner

@andreas-karlsson could you please sign the YUI CLA?

The CLA ensures that everyone who submits a work of authorship to the YUI Library is contributing work that is their own or for which they can authoritatively speak. This protects the tens of thousands of developers who use YUI in their daily work, all of whom rely on YUI's BSD license to appropriately cover their use of the library.

The CLA does not transfer title or copyright of your contributed work to Yahoo!. It merely guarantees that you approve the use of your work within YUI and by those who use the library under the terms of its license.

Thanks!

andreas.karlsson

Cool, the CLA is signed.

Satyen Desai
Collaborator

Hey Andreas, thanks for the pull request. There are a couple of small changes which I think are worth making:

a) Refactor the method to have a single return (just a readability/maintainability thing).

b) Add a check around the parentNode.appendChild(childBB). We don't want to append a child which already may be added to parentNode in it's correct position.

If you want, I'm happy to make these changes locally since they are pretty small, and give you credit for it, or if you want to send in another pull request I can pull it in.

andreas.karlsson
Satyen Desai
Collaborator

Cool. Fixed locally, with References to this pull request.

andreas.karlsson
Ryan Grove rgrove closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2011
  1. andreas.karlsson

    Made _uiAddChild always append the child's bb to the parent node whic…

    andreas-karlsson authored
    …h fixes #2531093
    
    Added a test for the issue.
  2. andreas.karlsson
This page is out of date. Refresh to see the latest.
22 src/widget-parent/js/Widget-Parent.js
View
@@ -731,14 +731,20 @@ Parent.prototype = {
if (nextSibling && nextSibling.get(RENDERED)) {
siblingBB = nextSibling.get(BOUNDING_BOX);
siblingBB.insert(childBB, "before");
- } else {
- prevSibling = child.previous(false);
-
- if (prevSibling && prevSibling.get(RENDERED)) {
- siblingBB = prevSibling.get(BOUNDING_BOX);
- siblingBB.insert(childBB, "after");
- }
- }
+ return;
+ }
+
+ prevSibling = child.previous(false);
+ if (prevSibling && prevSibling.get(RENDERED)) {
+ siblingBB = prevSibling.get(BOUNDING_BOX);
+ siblingBB.insert(childBB, "after");
+ return;
+ }
+
+ // In all other cases, make sure childBB is contained
+ // by the childrenContainer since it might have been
+ // previously rendered elsewhere
+ parentNode.append(childBB);
},
25 src/widget-parent/tests/parent-child.html
View
@@ -239,6 +239,31 @@
widget.destroy();
},
+ testAddWidgetToEmptyParent : function() {
+ var widget = new Y.ParentWidget({
+ id:"widget-1"
+ });
+
+ widget.render();
+
+ var child = new Y.ChildWidget({
+ id:"child-1"
+ });
+
+ child.render();
+
+ widget.add(child);
+
+ Y.Assert.areEqual(widget.size(1), 1, "expected one child");
+
+ var renderedChildren = widget.get("contentBox").get("children");
+
+ Y.Assert.areEqual(renderedChildren.size(), 1, "expected one child node");
+
+ widget.destroy();
+ child.destroy();
+ },
+
testRemove: function () {
var widget = new Y.ParentWidget({
Something went wrong with that request. Please try again.