diff --git a/docs/spec/domSpec.js b/docs/spec/domSpec.js
index d10db9dc7e82..cb4c00f250cb 100644
--- a/docs/spec/domSpec.js
+++ b/docs/spec/domSpec.js
@@ -9,11 +9,16 @@ describe('dom', function() {
});
describe('html', function() {
- it('should add ids to all h tags', function() {
+ it('should add ids to h tags', function() {
dom.html('
Some Header
');
expect(dom.toString()).toContain('');
});
+ it('should override existing h tag ids', function() {
+ dom.html('');
+ expect(dom.toString()).toContain('');
+ });
+
it('should collect anchors too', function() {
dom.html('Xxx and bar ');
expect(dom.anchors).toContain('foo');
diff --git a/docs/src/dom.js b/docs/src/dom.js
index e696faf4c1c7..cb15215df866 100644
--- a/docs/src/dom.js
+++ b/docs/src/dom.js
@@ -83,6 +83,7 @@ DOM.prototype = {
var id = idFromCurrentHeaders(self.currentHeaders);
self.anchors.push(id);
+ attrs = attrs.replace(/\sid=["'].+?["']/, '');
return '' + content + '';
});