Opened 7 years ago

Closed 7 years ago

#16264 closed defect (fixed)

ContentPane: single child detection treats css links as children

Reported by: Rubbinio Owned by: Rubbinio
Priority: undecided Milestone: 1.9
Component: Dijit Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

If you have a border container and inside it you try to load a page which has a css import link, a script tag and another content pane the singleChildDetection method fails to detect the content pane as single child.

The problem can be traced to this method in _ContentPaneResizeMixin:

_checkIfSingleChild : function() {
		    // summary:
		    //		Test if we have exactly one visible widget as a child,
		    //		and if so assume that we are a container for that widget,
		    //		and should propagate startup() and resize() calls to it.
		    //		Skips over things like data stores since they aren't visible.

		    var candidateWidgets = [], otherVisibleNodes = false;

		    query("> *", this.containerNode).some(function(node) {
			    var widget = registry.byNode(node);
			    if (widget && widget.resize) {
				    candidateWidgets.push(widget);
			    } else if (node.offsetHeight) {
				    otherVisibleNodes = true;
			    }
		    });

		    this._singleChild = candidateWidgets.length == 1 && !otherVisibleNodes ? candidateWidgets[0] : null;

		    // So we can set overflow: hidden to avoid a safari bug w/scrollbars showing up (#9449)
		    domClass.toggle(this.containerNode, this.baseClass + "SingleChild", !!this._singleChild);
	    },

and more precisely to:

else if (node.offsetHeight) {
   otherVisibleNodes = true;
}

for some reason having something like <link href="/stylesheets/pages/mypage.css" type="text/css"/> will return a node.offsetHeight == 13 and break the single child detection.

However this works fine for script tags which return node.offsetHeight == 0

Change History (6)

comment:1 Changed 7 years ago by bill

Component: GeneralDijit
Milestone: tbd1.9
Owner: set to bill
Summary: Content Pane Single Child detection treats css links as childrenContentPane: single Child detection treats css links as children

Thanks for the report, makes sense, I will check in a fix.

comment:2 Changed 7 years ago by bill

In [29899]:

add test for <link> tag, refs #16264

comment:3 Changed 7 years ago by bill

Owner: changed from bill to Rubbinio
Status: newpending

Actually, it's working for me with the current code (see the test case I checked in), can you supply a test case that fails?

comment:4 Changed 7 years ago by Rubbinio

Status: pendingnew

The test you provided fails for me in FF16 and IE9 but passes in Chrome. Which is the same we are seeing in our application

PASSED test: script tags ignored 0 ms

dojo.js (line 709)

_AssertFailure: http://localhost:8080/dojoroot/1.8.1/dojo/dojo.js:362 assertTrue('null') failed with hint: link tag ignored, marked as single child

console.error(Array.prototype.join.call(arguments, " "))

_browserRunner.js (line 389)

ERROR IN:

(function (t) {doh.t(pane5._singleChild, "link tag ignored, marked as single child");})

dojo.js (line 709)

FAILED test: link tags ignored 3 ms

comment:5 Changed 7 years ago by bill

Summary: ContentPane: single Child detection treats css links as childrenContentPane: single child detection treats css links as children

I see, thanks. Strange it works in IE8 but not IE9. I'll add an extra to skip link nodes and (just in case) script nodes. Any other tags it's worth ignoring (ie, not even checking for offsetHeight)?

Last edited 7 years ago by bill (previous) (diff)

comment:6 Changed 7 years ago by bill

Resolution: fixed
Status: newclosed

In [29902]:

Ignore <link> tags when testing for ContentPane single child. For some reason on FF16 and IE9 they have offsetHeight > 0. Fixes #16264 !strict.

Note: See TracTickets for help on using tickets.