Giter Club home page Giter Club logo

sg's People

Contributors

driverx avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

i11v

sg's Issues

Замечания по некоторым методам

1 Должен ли SGUtils.isObj возвращать false на объект созданный конструктором?

function defaultOptions(){}
defaultOptions.prototype = {
  constructor: defaultOptions
  , option1: true
 <...>
}
var options = SGUtils.ext(new defaultOptions, { option1: false } )

Сейчас SGUtils.isObj(options) == false, из-за проверки на конструктор. А для чего конструктор проверяется?

2 jQuery.isPlaneObject не слишком хороший пример определения объект это или нет. Вот у нас в common такое:

var _toString_ = Object.prototype.toString;

if(!Object.isObject)Object.isObject = function(object) {
  return object
    && _toString_.call(object) === "[object Object]"
    && _toString_.call(object.constructor) === "[object Function]"
//DOM-objects in IE have _toString_.call(object.constructor) === "[object Object]"
  ;
};

Текущий вариант вернёт ложный результат в случае

SGUtils.isObj( { nodeType: 123 } )

Наш же вариант вернёт ложный результат в браузерах с нативной поддержкой Object.create в таком случае

Object.isObject( Object.create(null) ) == false;// :(

3 Полифил Function.prototype.bind из es5-shim выдаст ошибку в IE<9 при некоторых условиях, если в качестве this передавать DOM-объект

function(){}.bind(document.documentElement)

// может выдать exseption на строке
this instanceof emptyFn

//нужно ещё проверять, что это не DOM-объект
Object.isObject(this) && this instanceof emptyFn

4 В методах обхода по массиву не поддерживаются разряженные массивы:

a = [];
a[1] = 1;
a[10] = 10;

SGUtils.map(a, function(a){ return a + "1" }).join(",")

выдаст ",11,,,,,,,,,101" в нормальных браузерах и "undefined1,11,undefined1,undefined1,undefined1,undefined1,undefined1,undefined1,undefined1,undefined1,101" в старых IE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.