Skip to content

Commit

Permalink
initialized element
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenmcp committed Feb 19, 2018
0 parents commit 6f54278
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# \<deep-intersection-observer\>

Polymer element providing import of intersection observer polyfill.

## Install the Polymer-CLI

First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) installed. Then run `polymer serve` to serve your element locally.

## Viewing Your Element

```
$ polymer serve
```

## Running Tests

```
$ polymer test
```

Your application is already set up to be tested via [web-component-tester](https://github.com/Polymer/web-component-tester). Run `polymer test` to run your application's test suite locally.
31 changes: 31 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "deep-intersection-observer",
"description": "Polymer element providing import of intersection observer polyfill.",
"main": "deep-intersection-observer.html",
"dependencies": {
"polymer": "Polymer/polymer#^1.0 || ^2.0"
},
"devDependencies": {
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^2.0.0",
"web-component-tester": "Polymer/web-component-tester#^6.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0"
},
"resolutions": {
"polymer": "^2.0.0"
},
"variants": {
"1.x": {
"dependencies": {
"polymer": "Polymer/polymer#^1.9"
},
"devDependencies": {
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
"web-component-tester": "Polymer/web-component-tester#^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"resolutions": {
"webcomponentsjs": "^0.7"
}
}
}
}
36 changes: 36 additions & 0 deletions deep-intersection-observer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<link rel="import" href="../polymer/polymer-element.html">

<dom-module id="deep-intersection-observer">
<template>
<style>
:host {
display: block;
}
</style>
<h2>Hello [[prop1]]!</h2>
</template>

<script>
/**
* `deep-intersection-observer`
* Polymer element providing import of intersection observer polyfill.
*
* @customElement
* @polymer
* @demo demo/index.html
*/
class DeepIntersectionObserver extends Polymer.Element {
static get is() { return 'deep-intersection-observer'; }
static get properties() {
return {
prop1: {
type: String,
value: 'deep-intersection-observer'
}
};
}
}

window.customElements.define(DeepIntersectionObserver.is, DeepIntersectionObserver);
</script>
</dom-module>
30 changes: 30 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

<title>deep-intersection-observer demo</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../deep-intersection-observer.html">

<custom-style>
<style is="custom-style" include="demo-pages-shared-styles">
</style>
</custom-style>
</head>
<body>
<div class="vertical-section-container centered">
<h3>Basic deep-intersection-observer demo</h3>
<demo-snippet>
<template>
<deep-intersection-observer></deep-intersection-observer>
</template>
</demo-snippet>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=demo/" />
<title>deep-intersection-observer</title>
</head>
<body>
<!--
ELEMENT API DOCUMENTATION SUPPORT COMING SOON
Visit demo/index.html to see live examples of your element running.
This page will automatically redirect you there when run in the browser
with `polymer serve`.
-->
</body>
</html>
7 changes: 7 additions & 0 deletions polymer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lint": {
"rules": [
"polymer-2"
]
}
}
52 changes: 52 additions & 0 deletions test/deep-intersection-observer_test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

<title>deep-intersection-observer test</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>

<link rel="import" href="../deep-intersection-observer.html">
</head>
<body>

<test-fixture id="BasicTestFixture">
<template>
<deep-intersection-observer></deep-intersection-observer>
</template>
</test-fixture>

<test-fixture id="ChangedPropertyTestFixture">
<template>
<deep-intersection-observer prop1="new-prop1"></deep-intersection-observer>
</template>
</test-fixture>

<script>
suite('deep-intersection-observer', () => {

test('instantiating the element with default properties works', () => {
const element = fixture('BasicTestFixture');
assert.equal(element.prop1, 'deep-intersection-observer');
const elementShadowRoot = element.shadowRoot;
const elementHeader = elementShadowRoot.querySelector('h2');
assert.equal(elementHeader.innerHTML, 'Hello deep-intersection-observer!');
});

test('setting a property on the element works', () => {
// Create a test fixture
const element = fixture('ChangedPropertyTestFixture');
assert.equal(element.prop1, 'new-prop1');
const elementShadowRoot = element.shadowRoot;
const elementHeader = elementShadowRoot.querySelector('h2');
assert.equal(elementHeader.innerHTML, 'Hello new-prop1!');
});

});
</script>

</body>
</html>
18 changes: 18 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
// Load and run all tests (.html, .js):
WCT.loadSuites([
'deep-intersection-observer_test.html'
]);
</script>

</body></html>

0 comments on commit 6f54278

Please sign in to comment.