-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravel-airport.js
40 lines (32 loc) · 1.08 KB
/
travel-airport.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function() {
'use strict';
var airports = {
"DFW": {
"name":"Dallas/Fort Worth International Airport",
"region":"Texas",
"country":"US"
},
"ATL": {
"name":"Atlanta Something Something",
"region":"Atlanta",
"country":"US"
}
};
var AirportPrototype = Object.create(window.HTMLElement.prototype);
AirportPrototype.createdCallback = function() {
console.log("ohai")
var iataCode = this.getAttribute('iata-code');
console.log("iata", iataCode)
var airport = airports[iataCode];
console.log(airport);
this.innerHTML = "<b>I'm an airport!</b> " + iataCode + " " + airport["name"];
};
// Public: AirportElement constructor.
//
// var airport = new AirportElement()
// # => <airport></airport>
//
window.AirportElement = document.registerElement('travel-airport', {
prototype: AirportPrototype,
});
})();