MyDOM.js

Stavím JS knihovnu na práci s DOMem. Vlastně se jedná jen o ohnutí vanilla funkcí JSka na syntaxe jQuery.
Využití je právě na tomhle webu a prototypy dopisuju podle potřeby...
Nicméně je to tak jednoduše připravený, že si je můžete dopsat sami :)

Náhled verze na tomhle webu:

!(function(window) {
  "use strict";
  var MYD_ = function() {
    this._xhr_ = {
      default: {
        method: "GET",
        url: window.location.href,
        headers: [],
        post: {},
        statusCode: {}
      },
      accepts: {
        "*": null,
        text: "text/plain",
        html: "text/html",
        xml: "application/xml, text/xml",
        json: "application/json, text/javascript"
      },
      parse: true,
      sts: {},
      queue: []
    };
    this._xhr_.call = this._xhr_.default;
    this.elm = null;
  };
  MYD_.prototype = {
    _exception_: function(id, addit, el) {
      return {
        notfound: "Selector " + String(el) + " was not found in this document.",
        argmissing: "Argument missing, excepted: " + addit[0] + " arg.",
        badinput: "Bad input argument, excepted: " + addit[0] + ", got: " + addit[1]
      } [id];
    },
    _mydom_: function(el) {
      var lib = this,
        elm = el !== undefined && typeof el === "string" ? document.querySelectorAll(el) : null,
        ell = elm === null ? (el === undefined ? document : el) : (elm.length === 1 ? elm[0] : elm);
      if (el !== undefined && typeof el === "string" && !document.querySelectorAll(el).length) {
        return !1;
      }
      if (ell.length > 1) {
        var Els__ = function() {
            return ell;
          },
          _els_ = new Els__();
        _els_.each = function(fn) {
          if (fn === undefined) {
            throw Error(lib._exception_("argmissing", [1]));
          } else if ("function" !== typeof fn) {
            throw Error(lib._exception_("badinput", ["function", typeof fn]));
GitHub - dev branch