Skip to content

Commit

Permalink
[fix] Don't render if we don't have HTML or placeholders to append to.
Browse files Browse the repository at this point in the history
[fix] Transform QSA in to a proper array.
[fix] The render method will now return true/false as a render indication.
  • Loading branch information
3rd-Eden committed Jul 25, 2013
1 parent 9104cfd commit af803f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pipe/pagelet.js
Expand Up @@ -75,7 +75,7 @@ Pagelet.prototype.initialise = function initialise() {
*/
Pagelet.prototype.$ = function $(attribute, value) {
if (document && 'querySelectorAll' in document) {
return document.querySelectorAll('['+ attribute +'="'+ value +'"]');
return Array.prototype.slice.call(document.querySelectorAll('['+ attribute +'="'+ value +'"]'), 0);
}

//
Expand Down Expand Up @@ -181,13 +181,16 @@ Pagelet.prototype.prepare = function prepare(code) {
* Render the HTML template in to the placeholders.
*
* @param {String} html The HTML that needs to be added in the placeholders.
* @returns {Boolean} Successfully rendered a pagelet.
* @api private
*/
Pagelet.prototype.render = function render(html) {
if (!this.placeholders.length || !html) return false;

collection.each(this.placeholders, function (root) {
var div = document.createElement('div')
, borked = this.IEV < 7
, fragment;
var fragment = document.createDocumentFragment()
, div = document.createElement('div')
, borked = this.IEV < 7;

if (borked) root.appendChild(div);

Expand All @@ -200,6 +203,8 @@ Pagelet.prototype.render = function render(html) {
root.appendChild(fragment);
if (borked) root.removeChild(div);
}, this);

return true;
};

/**
Expand Down

0 comments on commit af803f3

Please sign in to comment.