Merge "Fix problem where gr-formatted-text would sometimes not display"
This commit is contained in:
commit
47689369e1
@ -201,7 +201,7 @@ limitations under the License.
|
||||
</div>
|
||||
</div>
|
||||
<template is="dom-if" if="[[comment.robot_id]]">
|
||||
<div class="robotId" hidden$="[[collapsed]]"">
|
||||
<div class="robotId" hidden$="[[collapsed]]">
|
||||
[[comment.robot_id]]
|
||||
</div>
|
||||
</template>
|
||||
|
@ -20,7 +20,10 @@
|
||||
is: 'gr-formatted-text',
|
||||
|
||||
properties: {
|
||||
content: String,
|
||||
content: {
|
||||
type: String,
|
||||
observer: '_contentChanged',
|
||||
},
|
||||
config: Object,
|
||||
noTrailingMargin: {
|
||||
type: Boolean,
|
||||
@ -51,6 +54,14 @@
|
||||
return this._blocksToText(this._computeBlocks(this.content));
|
||||
},
|
||||
|
||||
_contentChanged: function(content) {
|
||||
// In the case where the config may not be set (perhaps due to the
|
||||
// request for it still being in flight), set the content anyway to
|
||||
// prevent waiting on the config to display the text.
|
||||
if (this.config) { return; }
|
||||
this.$.container.textContent = content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a source string, update the DOM inside #container.
|
||||
*/
|
||||
@ -63,7 +74,8 @@
|
||||
}
|
||||
|
||||
// Add new content.
|
||||
this._computeNodes(this._computeBlocks(content)).forEach(function(node) {
|
||||
this._computeNodes(this._computeBlocks(content))
|
||||
.forEach(function(node) {
|
||||
container.appendChild(node);
|
||||
});
|
||||
},
|
||||
|
@ -32,6 +32,7 @@ limitations under the License.
|
||||
<script>
|
||||
suite('gr-formatted-text tests', function() {
|
||||
var element;
|
||||
var sandbox;
|
||||
|
||||
function assertBlock(result, index, type, text) {
|
||||
assert.equal(result[index].type, type);
|
||||
@ -45,6 +46,11 @@ limitations under the License.
|
||||
|
||||
setup(function() {
|
||||
element = fixture('basic');
|
||||
sandbox = sinon.sandbox.create();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('parse null undefined and empty', function() {
|
||||
@ -354,5 +360,22 @@ limitations under the License.
|
||||
var expected = 'Paragraph\n\n pre\n\nList\nOf\nItems\n\nQuote';
|
||||
assert.equal(result, expected);
|
||||
});
|
||||
|
||||
test('_contentOrConfigChanged not called without config', function() {
|
||||
var contentStub = sandbox.stub(element, '_contentChanged');
|
||||
var contentConfigStub = sandbox.stub(element, '_contentOrConfigChanged');
|
||||
element.content = 'some text';
|
||||
assert.isTrue(contentStub.called);
|
||||
assert.isFalse(contentConfigStub.called);
|
||||
});
|
||||
|
||||
test('_contentOrConfigChanged called with config', function() {
|
||||
var contentStub = sandbox.stub(element, '_contentChanged');
|
||||
var contentConfigStub = sandbox.stub(element, '_contentOrConfigChanged');
|
||||
element.content = 'some text';
|
||||
element.config = {};
|
||||
assert.isTrue(contentStub.called);
|
||||
assert.isTrue(contentConfigStub.called);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -35,9 +35,11 @@ limitations under the License.
|
||||
<script>
|
||||
suite('gr-linked-text tests', function() {
|
||||
var element;
|
||||
var sandbox;
|
||||
|
||||
setup(function() {
|
||||
element = fixture('basic');
|
||||
sandbox = sinon.sandbox.create();
|
||||
element.config = {
|
||||
ph: {
|
||||
match: '([Bb]ug|[Ii]ssue)\\s*#?(\\d+)',
|
||||
@ -68,6 +70,10 @@ limitations under the License.
|
||||
};
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('URL pattern was parsed and linked.', function() {
|
||||
// Reguar inline link.
|
||||
var url = 'https://code.google.com/p/gerrit/issues/detail?id=3650';
|
||||
@ -207,5 +213,35 @@ limitations under the License.
|
||||
assert.equal(links[1].href, 'ftp://foo/45');
|
||||
assert.equal(links[1].textContent, '45');
|
||||
});
|
||||
|
||||
test('_contentOrConfigChanged called with config', function() {
|
||||
var contentStub = sandbox.stub(element, '_contentChanged');
|
||||
var contentConfigStub = sandbox.stub(element, '_contentOrConfigChanged');
|
||||
element.content = 'some text';
|
||||
assert.isTrue(contentStub.called);
|
||||
assert.isTrue(contentConfigStub.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('gr-linked-text with null config', function() {
|
||||
var element;
|
||||
var sandbox;
|
||||
|
||||
setup(function() {
|
||||
element = fixture('basic');
|
||||
sandbox = sinon.sandbox.create();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
test('_contentOrConfigChanged not called without config', function() {
|
||||
var contentStub = sandbox.stub(element, '_contentChanged');
|
||||
var contentConfigStub = sandbox.stub(element, '_contentOrConfigChanged');
|
||||
element.content = 'some text';
|
||||
assert.isTrue(contentStub.called);
|
||||
assert.isFalse(contentConfigStub.called);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user