Ignore:
Timestamp:
06/24/12 16:25:01 (13 years ago)
Author:
hendrikvanantwerpen
Message:

[Client] Merged mockup into pages/ folder.
[Client] Make client more robust when pages have empty lines or multiple root nodes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/content.js

    r340 r347  
    9595                }
    9696               
     97                function getFirstNode(html) {
     98                    var nodeOrFragment = domConstruct.toDom(html);
     99                    if (nodeOrFragment instanceof Element) {
     100                        return nodeOrFragment;
     101                    }
     102                    if (nodeOrFragment instanceof DocumentFragment) {
     103                        console.warn("Fragment found, will only use first Element");
     104                        for (i in nodeOrFragment.childNodes) {
     105                            var node = nodeOrFragment.childNodes[i];
     106                            if (node instanceof Element) {
     107                                return node;
     108                            }
     109                        }
     110                    }
     111                    return domConstruct.toDom('<div>No Element found in template.</div>');
     112                }
     113
    97114                function mixinArgs(node) {
    98115                    var props = {};
     
    118135                // initialize page or create error message
    119136                .then(function(html){
    120                     var rootNode = domConstruct.toDom(html);
     137                    var rootNode = getFirstNode(html);
    121138                    mixinArgs(rootNode);
    122139                    contentPane.set('content',rootNode);
Note: See TracChangeset for help on using the changeset viewer.