diff --git a/common.blocks/attach/attach.js b/common.blocks/attach/attach.js index 2781de348..f359d0afb 100644 --- a/common.blocks/attach/attach.js +++ b/common.blocks/attach/attach.js @@ -31,6 +31,14 @@ provide(bemDom.declBlock(this.name, Control, /** @lends attach.prototype */{ return this._clear(data); }, + /** + * Returns file element + * @returns {attach__file} + */ + getFileElem : function() { + return this.findChildElem('file'); + }, + _clear : function(data) { var control = this._elem('control').domElem, name = control.attr('name'), @@ -47,7 +55,7 @@ provide(bemDom.declBlock(this.name, Control, /** @lends attach.prototype */{ (tabIndex? ' tabindex="' + tabIndex + '"' : '') + '/>'); - bemDom.destruct(this.findChildElem('file').domElem); + bemDom.destruct(this.getFileElem().domElem); this.domElem.append(this._elem('no-file').domElem); // use append because only detached before @@ -75,7 +83,7 @@ provide(bemDom.declBlock(this.name, Control, /** @lends attach.prototype */{ _updateFileElem : function() { var fileName = extractFileNameFromPath(this.getVal()); - this.findChildElem('file') && bemDom.destruct(this._elem('file').domElem); + this.getFileElem() && bemDom.destruct(this._elem('file').domElem); bemDom.append( this.domElem, diff --git a/common.blocks/attach/attach.spec.js b/common.blocks/attach/attach.spec.js index 2f33141d8..3d583faa2 100644 --- a/common.blocks/attach/attach.spec.js +++ b/common.blocks/attach/attach.spec.js @@ -37,6 +37,11 @@ describe('attach', function() { setFile('\\usr\\local\\file.png'); attach._elem('text').domElem.text().should.be.equal('file.png'); }); + + it('should have file element', function() { + setFile('file.png'); + Boolean(attach.getFileElem()).should.be.true; + }); }); describe('clear', function() {