Skip to content

Commit

Permalink
Avoid registering custom elements if already registered
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Mar 9, 2018
1 parent dc3f3bb commit be29a0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/relative-time-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ function updateNowElements() {
// var time = new RelativeTimeElement()
// # => <relative-time></relative-time>
//
window.RelativeTimeElement = RelativeTimeElement
window.customElements.define('relative-time', RelativeTimeElement)
if (!window.customElements.get('relative-time')) {
window.RelativeTimeElement = RelativeTimeElement
window.customElements.define('relative-time', RelativeTimeElement)
}
6 changes: 4 additions & 2 deletions src/time-ago-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export default class TimeAgoElement extends RelativeTimeElement {
}
}

window.TimeAgoElement = TimeAgoElement
window.customElements.define('time-ago', TimeAgoElement)
if (!window.customElements.get('time-ago')) {
window.TimeAgoElement = TimeAgoElement
window.customElements.define('time-ago', TimeAgoElement)
}
6 changes: 4 additions & 2 deletions src/time-until-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export default class TimeUntilElement extends RelativeTimeElement {
}
}

window.TimeUntilElement = TimeUntilElement
window.customElements.define('time-until', TimeUntilElement)
if (!window.customElements.get('time-until')) {
window.TimeUntilElement = TimeUntilElement
window.customElements.define('time-until', TimeUntilElement)
}

0 comments on commit be29a0a

Please sign in to comment.