Ticket #2531287 (accepted enhancement)

Reporter


Jonathan Potter
Opened: 10/10/11
Last modified: 09/19/12
Status: accepted
Type: enhancement

Owner


Eric Ferraiuolo
Target Release: BACKLOG
Priority: P2 (high)
Summary: Widget-StdMod: Elements added to the bodyContent during subclass's renderUI phase are added twice
Description:

Steps to reproduce:
# Create a simple widget class that extends Y.Widget and augments Y.WidgetStdMod
# In the renderUI function set the bodyContent (via this.set("bodyContent", node))
# Add a logging statement in widget-stdmod.js in the _addStdModContent function (for example: console.log("_addStdModContent"); console.log(node);)
# Run render your widget to a page

Expected behavior: "_addStdModContent" prints once.
Actual behavior: "_addStdModContent" prints twice.

This only happens when bodyContent is set during the renderUI phase. I think the reason this is happening because of the following. _renderUIStdMod listens for the bodyContent change with:


this.after(BodyChange, this._afterBodyChange);

But _syncUIStdMod also checks to see if the bodyContent has changed which it does by checking if _stdModParsed is set. So when bodyContent is set in the subclass's renderUI function, _renderUIStdMod
fires which adds the content to the DOM, but it doesn't set _stdModParsed because _findStdModSection returns null. Therefore when _syncUIStdMod runs during the sync stage, it checks to see if
_stdModParsed is set, which it isn't, so it goes ahead and adds the elements to the DOM again.

Type: enhancement Observed in Version: development master
Component: Overlay Severity: S3 (normal)
Assigned To: Eric Ferraiuolo Target Release: BACKLOG
Location: Library Code Priority: P2 (high)
Tags: Relates To:
Browsers: Safari 5.x - Mac,Chrome
URL:
Test Information:

Change History

Jenny Donnelly

YUI Developer

Posted: 10/10/11
  • component changed from None to Widget
  • location changed to Library Code
  • owner changed from Jenny Donnelly to Satyen Desai
  • priority changed to P3 (normal)
  • status changed from new to assigned

Satyen Desai

YUI Developer

Posted: 11/8/11

Eric Ferraiuolo

YUI Developer

Posted: 11/8/11
  • milestone changed to 3.5.0
  • status changed from assigned to accepted

Eric Ferraiuolo

YUI Developer

Posted: 11/8/11
  • estimated changed from 0 to 0.25
  • remaining changed from 0 to 0.25
  • sprint changed to sprint 2

Eric Ferraiuolo

YUI Developer

Posted: 12/14/11
  • priority changed from P3 (normal) to P2 (high)
  • severity changed from S3 (normal) to S2 (high)
  • sprint changed from sprint 2 to sprint 3

Eric Ferraiuolo

YUI Developer

Posted: 02/16/12
  • estimated changed from 0.25 to 1
  • milestone changed from 3.5.0 to 3.6.0
  • remaining changed from 0.25 to 1
  • severity changed from S2 (high) to S3 (normal)
  • sprint changed from sprint 3
  • type changed from defect to enhancement

Punting on this for now. It doesn't add duplicate content, but it is doing unnecessary work which should be optimized for performance.

I created a jsFiddle which shows the content only being rendered once, but a lot of event firing:
http://jsfiddle.net/ericf/r5Rsp/

Eric Ferraiuolo

YUI Developer

Posted: 04/9/12
  • sprint changed to backlog

Eric Ferraiuolo

YUI Developer

Posted: 07/9/12
  • milestone changed from 3.6.0 to 3.NEXT
  • sprint changed from backlog

Jenny Donnelly

YUI Developer

Posted: 09/19/12
  • milestone changed from 3.NEXT to BACKLOG

Moving from 3.NEXT to BACKLOG.