-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a Polymer 3 element template to init
.
#115
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1438c47
Copy `polymer-2.x` template to `polymer-3.x`.
bicknellr d3f365a
Update `init` and associated polymer-3.x template.
bicknellr 5d116f7
Update `README.md`.
bicknellr 5e3f069
Format, excluding broken changes due to templating.
bicknellr ade3349
Merge remote-tracking branch 'origin/master' into init-3.x-element
bicknellr 1b00b80
Merge remote-tracking branch 'origin/master' into init-3.x-element
bicknellr 1e1439c
Move templates to a folder in the package root so that they aren't ch…
bicknellr 1a6be11
Install dependencies after writing the template.
bicknellr f9de6b3
Add an integration test for the Polymer 3 element template.
bicknellr c556f4b
Update TODOs with issue numbers.
bicknellr 1fc67fa
Add comments and explicit pass-through methods because of a Yeoman bug.
bicknellr d493ae2
Merge remote-tracking branch 'origin/master' into init-3.x-element
bicknellr bdd7977
Update pass-through function comments with Yeoman bug number.
bicknellr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# \<<%= name %>\> | ||
|
||
<%= description %> | ||
|
||
## Install the Polymer-CLI | ||
|
||
First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) and npm (packaged with [Node.js](https://nodejs.org)) installed. Run `npm install` to install your element's dependencies, 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. |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {PolymerElement} from '@polymer/polymer/polymer-element.js'; | ||
|
||
/** | ||
* `<%= name %>` | ||
* <%= description %> | ||
* | ||
* @customElement | ||
* @polymer | ||
* @demo demo/index.html | ||
*/ | ||
class <%= elementClassName %> extends PolymerElement { | ||
static get template() { | ||
return ` | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
<h2>Hello [[prop1]]!</h2> | ||
`; | ||
} | ||
static get properties() { | ||
return { | ||
prop1: { | ||
type: String, | ||
value: '<%= name %>', | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
window.customElements.define('<%= name %>', <%= elementClassName %>); |
30 changes: 30 additions & 0 deletions
30
packages/cli/templates/element/polymer-3.x/demo/index.html
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 |
---|---|---|
@@ -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><%= name %> demo</title> | ||
|
||
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> | ||
|
||
<script type="module" src="../node_modules/@polymer/iron-demo-helpers/demo-pages-shared-styles.js"></script> | ||
<script type="module" src="../node_modules/@polymer/iron-demo-helpers/demo-snippet.js"></script> | ||
<script type="module" src="../<%= name %>.js"></script> | ||
|
||
<custom-style> | ||
<style is="custom-style" include="demo-pages-shared-styles"> | ||
</style> | ||
</custom-style> | ||
</head> | ||
<body> | ||
<div class="vertical-section-container centered"> | ||
<h3>Basic <%= name %> demo</h3> | ||
<demo-snippet> | ||
<template> | ||
<<%= name %>></<%= name %>> | ||
</template> | ||
</demo-snippet> | ||
</div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="refresh" content="0;url=demo/" /> | ||
<title><%= name %></title> | ||
</head> | ||
<body> | ||
<!-- | ||
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> |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "<%= name %>", | ||
<% if (description) { -%> "description": "<%= description %>", | ||
<% } -%> | ||
"main": "<%= name %>.js", | ||
"dependencies": { | ||
"@polymer/polymer": "^3.0.0-pre.12" | ||
}, | ||
"devDependencies": { | ||
"@polymer/iron-demo-helpers": "^3.0.0-pre.12", | ||
"@webcomponents/webcomponentsjs": "^1.0.0", | ||
"wct-browser-legacy": "^0.0.1-pre.11" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"npm": true, | ||
"moduleResolution": "node" | ||
} |
52 changes: 52 additions & 0 deletions
52
packages/cli/templates/element/polymer-3.x/test/_element_test.html
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 |
---|---|---|
@@ -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><%= name %> test</title> | ||
|
||
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> | ||
<script src="../node_modules/wct-browser-legacy/browser.js"></script> | ||
|
||
<script type="module" src="../<%= name %>.js"></script> | ||
</head> | ||
<body> | ||
|
||
<test-fixture id="BasicTestFixture"> | ||
<template> | ||
<<%= name %>></<%= name %>> | ||
</template> | ||
</test-fixture> | ||
|
||
<test-fixture id="ChangedPropertyTestFixture"> | ||
<template> | ||
<<%= name %> prop1="new-prop1"></<%= name %>> | ||
</template> | ||
</test-fixture> | ||
|
||
<script type="module"> | ||
suite('<%= name %>', () => { | ||
|
||
test('instantiating the element with default properties works', () => { | ||
const element = fixture('BasicTestFixture'); | ||
assert.equal(element.prop1, '<%= name %>'); | ||
const elementShadowRoot = element.shadowRoot; | ||
const elementHeader = elementShadowRoot.querySelector('h2'); | ||
assert.equal(elementHeader.innerHTML, 'Hello <%= name %>!'); | ||
}); | ||
|
||
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> |
17 changes: 17 additions & 0 deletions
17
packages/cli/templates/element/polymer-3.x/test/index.html
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!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="../node_modules/wct-browser-legacy/browser.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
// Load and run all tests (.html, .js): | ||
WCT.loadSuites([ | ||
'<%= name %>_test.html' | ||
]); | ||
</script> | ||
</body> | ||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you double check that this doesn't work when this isn't here? I looked at the JS that's produced, and we're producing ES6 here. I can't see any reason why this code would do anything at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like async-await is being compiled out. I'm betting it has something to do with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, yes, the parent class'
prompting
function isn't called if this isn't here. I can't figure out where yeoman-generator calls it though and I'm not sure how it gets called due to the async-await thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, telling TypeScript to target ES2017 still has this problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the problem: https://github.com/yeoman/generator/blob/v1.0.1/lib/index.js#L382
Yeoman only checks the object's prototype's own properties, so I think I have to have something like this in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added pass-through functions for all of the other methods as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hey, you found it too. I just filed yeoman/generator#1065