Giter VIP home page Giter VIP logo

bem-priv's People

Contributors

dimitrydushkin avatar l0stsoul avatar notary avatar sbmaxx avatar tenorok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bem-priv's Issues

.props()

По аналогии с .prop(), только несколько атрибутов за раз.

Can't return empty value without overloading #bemjson method

Now, if I need to return empty value instead of block in some cases, I have to write some redundant code:

// old implementation using "blocks"
blocks['my-block'] = function(data) {
  if (!data.myData) return '';
  return { blocks: 'my-block', content: data.myData };
}

// "bempriv" implementation
BEMPRIV.decl('my-block', {
  init: function() {
    if (!this.data.myData) return;
    this.content(this.data.myData);
  },
  bemjson: function() {
    if (this.data.myData) {
      return this.__base();
    }
  }
}

Probably, it worth to implement some way to reach that without overloading bemjson method.

Choose API for blocks with mods creation/constructors.

Declarations are easy

BEMPRIV.decl({ block: 'block', modName: 'mod', modValue: 'value' };

But what about creation? We have at least two popular approachs to create block:

BEMPRIV.create('block');
BEMPRIV.json('block'); // alias for BEMPRIV.create('block').bemjson();

The default __constructor accept two parameters data, params.

We have to choose new API for __constructor and BEMPRIV.create.

Unit-testing stub support

Было бы круто, если этот код работал бы =):

stubBlock = function(name, fn) {

    var stub;

    beforeEach(function() {
        stub = blocks[name]
            ? sinon.stub(blocks, name, fn)
            : BEMPRIV.stub(name);
    });

    afterEach(function() {
        blocks[name]
            ? stub.restore()
            : BEMPRIV.restore(name);
    });

}

ну или типа того. В общем, хорошо бы, если можно было бы стабать BEMPRIV блоки.

Добавление параметров js, mods, content и т.д.

Например, если надо добавить какое-то свойтво в mods, то надо писать так:

this.mods(_.assign(this.mods, { newProp: value });

Хорошо бы какой-нибудь хелпер для таких ситуаций, ну или прокачать mods(), чтобы он понимал, что надо расширить объект, а не заменять его.

Add custom properties setters

We need this BEMJSON:

{  
   block: 'one',
   title: 'we need custom props'
}

Code:

BEMPRIV.decl('one', {
    init: function() {
        this._property('title', undefined, 'we need custom props');
    }
});

It would be great to write:

BEMPRIV.decl('one', {
    init: function() {
        this.title('we need custom props');
    }
});

Ошибка в deepProp, если в init вернуть пустую строку

На данном коде bempriv выпадает с ошибкой

BEMPRIV.decl({

    block: 'direct',
    modName: 'serp-list',
    modVal: 'yes'

}, {

    init: function() {
        return '';
    },

    test: function() {

    }

});

var priv = BEMPRIV.create({ block: 'direct', mods: { 'serp-list': 'yes' } });

priv.test();

Ошибка:

            return this._bemjson[prop][key];
                                      ^
TypeError: Cannot read property 'serp-list' of undefined

Отваливается здесь:

deepProp : function(prop, key, value) {

        if (typeof this._bemjson[prop] === 'undefined') {
            this._bemjson[prop] = {};
        }

        if (typeof value === 'undefined') {
            return this._bemjson[prop][key]; \\ Отваливается тут
        }

        this._bemjson[prop][key] = value;
        return this;

    }

Как я понял bempriv пытается найти модификатор, указанный при декларации, в bemjson. Но в данном конкретном случае bemjson равен пустой строке, потому что init возвращает пустую строку.

Short name

BEMPRIV -> BP
with backward compatible.

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.