-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Due to documented problems of transpiled ES2015 classes and extending native constructors (babel/babel/issues/4480), I had to use the V0 api, it all works fine in development but build is broken
- Loading branch information
Manuel Mujica
committed
Nov 17, 2016
1 parent
47e7ee4
commit 8061979
Showing
5 changed files
with
58 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
import '@webcomponents/custom-elements#?needs-polyfill'; | ||
import 'document-register-element#?needs-polyfill'; | ||
import './styles.css'; | ||
|
||
class BitProduct extends HTMLElement { | ||
constructor() { | ||
super(); | ||
document.registerElement('bit-product', { | ||
prototype: Object.create(HTMLElement.prototype, { | ||
createdCallback: { | ||
value() { | ||
this.appendChild(this._makeLinkElement()); | ||
} | ||
}, | ||
|
||
this.appendChild(this._makeLinkElement()); | ||
} | ||
_makeLinkElement: { | ||
value() { | ||
let link = document.createElement('a'); | ||
|
||
_makeLinkElement() { | ||
let link = document.createElement('a'); | ||
link.href = this.getAttribute('data-url'); | ||
link.appendChild(this._makeFigureElement()); | ||
|
||
link.href = this.getAttribute('data-url'); | ||
link.appendChild(this._makeFigureElement()); | ||
return link; | ||
} | ||
}, | ||
|
||
return link; | ||
} | ||
_makeFigureElement: { | ||
value() { | ||
let figure = document.createElement('figure'); | ||
|
||
_makeFigureElement() { | ||
let figure = document.createElement('figure'); | ||
|
||
figure.appendChild(this._makeImageElement()); | ||
figure.appendChild(this._makeCaptionElement()); | ||
|
||
figure.appendChild(this._makeImageElement()); | ||
figure.appendChild(this._makeCaptionElement()); | ||
return figure; | ||
} | ||
}, | ||
|
||
return figure; | ||
} | ||
_makeImageElement: { | ||
value() { | ||
let img = document.createElement('img'); | ||
|
||
_makeImageElement() { | ||
let img = document.createElement('img'); | ||
img.alt = this.getAttribute('data-name'); | ||
img.src = this.getAttribute('data-img'); | ||
img.className = 'product-img'; | ||
|
||
img.alt = this.getAttribute('data-name'); | ||
img.src = this.getAttribute('data-img'); | ||
img.className = 'product-img'; | ||
return img; | ||
}, | ||
}, | ||
|
||
return img; | ||
} | ||
_makeCaptionElement: { | ||
value() { | ||
let caption = document.createElement('figcaption'); | ||
|
||
_makeCaptionElement() { | ||
let caption = document.createElement('figcaption'); | ||
|
||
caption.innerText = this.getAttribute('data-caption'); | ||
return caption; | ||
} | ||
} | ||
|
||
customElements.define('bit-product', BitProduct); | ||
caption.innerText = this.getAttribute('data-caption'); | ||
return caption; | ||
} | ||
} | ||
}) | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
export default (typeof customElements === 'undefined'); | ||
// Only NodeJS has a process variable that is of [[Class]] process | ||
const __process = typeof process !== 'undefined' ? process : 0; | ||
const isNodeJS = Object.prototype.toString.call(__process) === '[object process]'; | ||
|
||
// prevent undefined reference errors during build, only needed because | ||
// steal-conditional will load this module during build to make sure it is | ||
// added to the main bundle | ||
export default isNodeJS ? | ||
null : | ||
typeof document.registerElement === 'undefined'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters