Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit cd52d4c

Browse files
biggiemanProLoser
authored andcommitted
public renderElement method (#30)
1 parent fcd6288 commit cd52d4c

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

dist/mention.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,21 @@ angular.module('ui.mention').controller('uiMention', ["$element", "$scope", "$at
108108
_this2.mentions.forEach(function (mention) {
109109
html = html.replace(_this2.encode(mention), _this2.highlight(mention));
110110
});
111-
$element.next().html(html);
111+
_this2.renderElement().html(html);
112112
return html;
113113
};
114114

115+
/**
116+
* $mention.renderElement()
117+
*
118+
* Get syntax-encoded HTML element
119+
*
120+
* @return {Element} HTML element
121+
*/
122+
this.renderElement = function () {
123+
return $element.next();
124+
};
125+
115126
/**
116127
* $mention.highlight()
117128
*

dist/mention.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mentionController.es6.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,21 @@ angular.module('ui.mention')
8484
this.mentions.forEach( mention => {
8585
html = html.replace(this.encode(mention), this.highlight(mention));
8686
});
87-
$element.next().html(html);
87+
this.renderElement().html(html);
8888
return html;
8989
};
9090

91+
/**
92+
* $mention.renderElement()
93+
*
94+
* Get syntax-encoded HTML element
95+
*
96+
* @return {Element} HTML element
97+
*/
98+
this.renderElement = () => {
99+
return $element.next();
100+
};
101+
91102
/**
92103
* $mention.highlight()
93104
*

test/uiMentionController.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('uiMention', () => {
6060
});
6161

6262
[
63-
'init', 'render', 'highlight', 'decode', 'label', 'encode', 'replace',
63+
'init', 'render', 'renderElement', 'highlight', 'decode', 'label', 'encode', 'replace',
6464
'select', 'up', 'down', 'search', 'findChoices', 'cancel', 'autogrow'
6565
].forEach((fn) => {
6666
it(fn + ' is a public API method on ' + ctrlInstance, () => {
@@ -203,10 +203,14 @@ describe('uiMention', () => {
203203
expect(ctrlInstance.render()).to.not.eq('<span>wat nope</span>');
204204
});
205205

206+
it('checks the render html element', () => {
207+
expect(ctrlInstance.renderElement()).to.have.property('html');
208+
});
209+
206210
it('replaces the html of $element.next with the converted value', () => {
207211
ngModel.$modelValue = '@[foo bar:1] @[k v:2]';
208212
ctrlInstance.render();
209-
expect($element.next().html()).to.eq('<span>foo bar</span> <span>k v</span>')
213+
expect(ctrlInstance.renderElement().html()).to.eq('<span>foo bar</span> <span>k v</span>')
210214
});
211215
});
212216

0 commit comments

Comments
 (0)