Skip to content

Commit

Permalink
Merge pull request #564 from bem/portCommits@2.x
Browse files Browse the repository at this point in the history
Port commits from dev branch
  • Loading branch information
tadatuta committed Nov 4, 2014
2 parents 9e5578a + d86d64a commit 9e2b8f0
Show file tree
Hide file tree
Showing 16 changed files with 357 additions and 149 deletions.
18 changes: 12 additions & 6 deletions blocks-common/i-bem/__dom/i-bem__dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,67 +1115,73 @@ var DOM = BEM.DOM = BEM.decl('i-bem__dom', {
* @param {jQuery|String} content New content
* @param {Function} [callback] Handler to be called after initialization
* @param {Object} [callbackCtx] Handler's context
* @returns {jQuery} ctx Initialization context
*/
update : function(ctx, content, callback, callbackCtx) {

this.destruct(ctx, true);
this.init(ctx.html(content), callback, callbackCtx);
return this.init(ctx.html(content), callback, callbackCtx);

},

/**
* Changes a fragment of the DOM tree including the context and initializes blocks.
* @param {jQuery} ctx Root DOM node
* @param {jQuery|String} content Content to be added
* @returns {jQuery} ctx Initialization context
*/
replace : function(ctx, content) {

this.destruct(true, ctx);
this.init($(content).replaceAll(ctx));
return this.init($(content).replaceAll(ctx));

},

/**
* Adds a fragment of the DOM tree at the end of the context and initializes blocks
* @param {jQuery} ctx Root DOM node
* @param {jQuery|String} content Content to be added
* @returns {jQuery} ctx Initialization context
*/
append : function(ctx, content) {

this.init($(content).appendTo(ctx));
return this.init($(content).appendTo(ctx));

},

/**
* Adds a fragment of the DOM tree at the beginning of the context and initializes blocks
* @param {jQuery} ctx Root DOM node
* @param {jQuery|String} content Content to be added
* @returns {jQuery} ctx Initialization context
*/
prepend : function(ctx, content) {

this.init($(content).prependTo(ctx));
return this.init($(content).prependTo(ctx));

},

/**
* Adds a fragment of the DOM tree before the context and initializes blocks
* @param {jQuery} ctx Contextual DOM node
* @param {jQuery|String} content Content to be added
* @returns {jQuery} ctx Initialization context
*/
before : function(ctx, content) {

this.init($(content).insertBefore(ctx));
return this.init($(content).insertBefore(ctx));

},

/**
* Adds a fragment of the DOM tree after the context and initializes blocks
* @param {jQuery} ctx Contextual DOM node
* @param {jQuery|String} content Content to be added
* @returns {jQuery} ctx Initialization context
*/
after : function(ctx, content) {

this.init($(content).insertAfter(ctx));
return this.init($(content).insertAfter(ctx));

},

Expand Down
2 changes: 1 addition & 1 deletion blocks-common/i-bem/__html/i-bem__html.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ this._mode === '' {
this.block = vBlock || (vElem ? block : undefined),
this._currBlock = vBlock || vElem ? undefined : block,
this.elem = this.ctx.elem,
this.mods = (vBlock ? this.ctx.mods : this.mods) || {},
this.mods = vBlock? this.ctx.mods || (this.ctx.mods = {}) : this.mods,
this.elemMods = this.ctx.elemMods || {}
) {
(this.block || this.elem) ?
Expand Down
Loading

0 comments on commit 9e2b8f0

Please sign in to comment.