Skip to content

Commit

Permalink
Lazy makes work more ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
humancopy committed Dec 20, 2017
1 parent bd5c90f commit d327c0b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/peace.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ var peaceJS;

options = options || {};

// Got a DOM element, array of objects (so get only the first one) or jQuery object
if (options.nodeType || (options[0] && options[0].nodeType)) options = {target: options[0] || options};
// Default
else options.target = script_tag && (script_tag.getAttribute('data-target') || script_tag.parentNode);

// if the target is a text let's find it
if (typeof options.target == 'string' && options.target != '') options.target = document.querySelector(options.target);
// If options is not an object we assume we got a DOM element (either string, element, jQuery object etc...)
if (options.constructor != Object) options = {target: options};

// No target at all, use the parent of the <script> tag
if (!options.target) options.target = script_tag && (script_tag.getAttribute('data-target') || script_tag.parentNode);
// If the target is a text let's find it
else if (typeof options.target == 'string') options.target = document.querySelector(options.target);
// Assume we got a jQuery object
else if (!options.target.nodeType) options.target = options.target[0];

// possible options: text, symbol
options.style = options.style || script_tag.getAttribute('data-style') || 'text';
Expand Down

0 comments on commit d327c0b

Please sign in to comment.