src/toastify.js
function() {
      // Creating the DOM object for the toast
      var toastElement = this.buildToast();

      // Getting the root element to with the toast needs to be added
      var rootElement;
      if (typeof this.options.selector === "undefined") {
        rootElement = document.body;
      } else {
        rootElement = document.getElementById(this.options.selector);
      }

      // Validating if root element is present in DOM
      if (!rootElement) {
        throw "Root element is not defined";
      }

      // Adding the DOM element
      rootElement.insertBefore(toastElement, rootElement.firstChild);

      // Repositioning the toasts in case multiple toasts are present
      Toastify.reposition();

      toastElement.timeOutValue = window.setTimeout(
        function() {
          // Remove the toast from DOM
          this.removeElement(toastElement);
        }.bind(this),
        this.options.duration
      ); // Binding `this` for function invocation

      // Supporting function chaining
      return this;
    }
function() {
      // Creating the DOM object for the toast
      var toastElement = this.buildToast();

      // Getting the root element to with the toast needs to be added
      var rootElement;
      if (typeof this.options.selector === "undefined") {
        rootElement = document.body;
      } else {
        rootElement = document.getElementById(this.options.selector);
      }

      // Validating if root element is present in DOM
      if (!rootElement) {
        throw "Root element is not defined";
      }

      // Adding the DOM element
      rootElement.insertBefore(toastElement, rootElement.firstChild);

      // Repositioning the toasts in case multiple toasts are present
      Toastify.reposition();

      toastElement.timeOutValue = window.setTimeout(
        function() {
          // Remove the toast from DOM
          this.removeElement(toastElement);
        }.bind(this),
        this.options.duration
      ); // Binding `this` for function invocation

      // Supporting function chaining
      return this;
    }
function ( ) { // Creating the DOM object for the toast var toastElement = this . buildToast ( ) ; // Getting the root element to with the toast needs to be added var rootElement ; if ( typeof this . options . selector === "undefined" ) { rootElement = document . body ; } else { rootElement = document . getElementById ( this . options . selector ) ; } // Validating if root element is present in DOM if ( ! rootElement ) { throw "Root element is not defined" ; } // Adding the DOM element rootElement . insertBefore ( toastElement , rootElement . firstChild ) ; // Repositioning the toasts in case multiple toasts are present Toastify . reposition ( ) ; toastElement . timeOutValue = window . setTimeout ( function ( ) { // Remove the toast from DOM this . removeElement ( toastElement ) ; } . bind ( this ) , this . options . duration ) ; // Binding `this` for function invocation // Supporting function chaining return this ; }
Displaying the toast
Displaying the toast