This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from Polymer/master
6/17 master -> stable
- Loading branch information
Showing
28 changed files
with
3,578 additions
and
919 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Names should be added to this file with this pattern: | ||
# | ||
# For individuals: | ||
# Name <email address> | ||
# | ||
# For organizations: | ||
# Organization <fnmatch pattern> | ||
# | ||
Google Inc. <*@google.com> |
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,63 @@ | ||
# Contributing | ||
|
||
Want to contribute to Polymer? Great! | ||
|
||
We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests. | ||
|
||
## Contributor License Agreement | ||
|
||
Before we can accept patches, there's a quick web form you need to fill out. | ||
|
||
- If you're contributing as and individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html). | ||
- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead. | ||
|
||
This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE). | ||
|
||
Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more. | ||
|
||
[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement) | ||
|
||
## Initial setup | ||
|
||
Here's an easy guide that should get you up and running: | ||
|
||
1. Fork the project on github and pull down your copy. | ||
> replace the {{ username }} with your username and {{ repository }} with the repository name | ||
git clone [email protected]:{{ username }}/{{ repository }}.git --recursive | ||
|
||
Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually: | ||
|
||
git submodule init | ||
git submodule update | ||
|
||
2. Development happens on the `master` branch. Get yourself on it! | ||
|
||
git checkout master | ||
|
||
That's it for the one time setup. Now you're ready to make a change. | ||
|
||
## Submitting a pull request | ||
|
||
We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change: | ||
|
||
git remote add upstream git://github.com/Polymer/{{ repository }}.git | ||
|
||
Then before making a change, do a pull from the upstream `master` branch: | ||
|
||
git pull upstream master | ||
|
||
To make life easier, add a "pull upstream" alias in your `.gitconfig`: | ||
|
||
[alias] | ||
pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master" | ||
|
||
That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo: | ||
|
||
git checkout master | ||
git pu | ||
# make change | ||
git commit -a -m 'Awesome things.' | ||
git push | ||
|
||
Lastly, don't forget to submit the pull request. |
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,23 @@ | ||
Additional IP Rights Grant (Patents) | ||
|
||
"This implementation" means the copyrightable works distributed by | ||
Google as part of the Polymer project. | ||
|
||
Google hereby grants to You a perpetual, worldwide, non-exclusive, | ||
no-charge, royalty-free, irrevocable (except as stated in this section) | ||
patent license to make, have made, use, offer to sell, sell, import, | ||
transfer and otherwise run, modify and propagate the contents of this | ||
implementation of Polymer, where such license applies only to those | ||
patent claims, both currently owned or controlled by Google and acquired | ||
in the future, licensable by Google that are necessarily infringed by | ||
this implementation of Polymer. This grant does not include claims | ||
that would be infringed only as a consequence of further modification of | ||
this implementation. If you or your agent or exclusive licensee | ||
institute or order or agree to the institution of patent litigation | ||
against any entity (including a cross-claim or counterclaim in a | ||
lawsuit) alleging that this implementation of Polymer or any code | ||
incorporated within this implementation of Polymer constitutes | ||
direct or contributory patent infringement, or inducement of patent | ||
infringement, then any patent rights granted to you under this License | ||
for this implementation of Polymer shall terminate as of the date | ||
such litigation is filed. |
Submodule buildbot
deleted from
3a4761
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,89 @@ | ||
// Sample Karma configuration file, that contain pretty much all the available options | ||
// It's used for running client tests on Travis (http://travis-ci.org/#!/karma-runner/karma) | ||
// Most of the options can be overriden by cli arguments (see karma --help) | ||
// | ||
// For all available config options and default values, see: | ||
// https://github.com/karma-runner/karma/blob/stable/lib/config.js#L54 | ||
|
||
|
||
// base path, that will be used to resolve files and exclude | ||
basePath = '../'; | ||
|
||
// list of files / patterns to load in the browser | ||
files = [ | ||
'node_modules/chai/chai.js', | ||
'conf/mocha.conf.js', | ||
'tests/setup.js', | ||
'mdv.js', | ||
'tests/*.js', | ||
{pattern: 'src/*.css', included: false}, | ||
{pattern: 'src/*.js', included: false}, | ||
{pattern: 'util/*.js', included: false}, | ||
{pattern: 'third_party/**/*.js', included: false} | ||
]; | ||
|
||
// list of files to exclude | ||
exclude = []; | ||
|
||
frameworks = ['mocha']; | ||
|
||
// use dots reporter, as travis terminal does not support escaping sequences | ||
// possible values: 'dots', 'progress', 'junit', 'teamcity' | ||
// CLI --reporters progress | ||
reporters = ['progress']; | ||
|
||
// web server port | ||
// CLI --port 9876 | ||
port = 9876; | ||
|
||
// cli runner port | ||
// CLI --runner-port 9100 | ||
runnerPort = 9100; | ||
|
||
// enable / disable colors in the output (reporters and logs) | ||
// CLI --colors --no-colors | ||
colors = true; | ||
|
||
// level of logging | ||
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG | ||
// CLI --log-level debug | ||
logLevel = LOG_INFO; | ||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
// CLI --auto-watch --no-auto-watch | ||
autoWatch = true; | ||
|
||
// Start these browsers, currently available: | ||
// - Chrome | ||
// - ChromeCanary | ||
// - Firefox | ||
// - Opera | ||
// - Safari (only Mac) | ||
// - PhantomJS | ||
// - IE (only Windows) | ||
// CLI --browsers Chrome,Firefox,Safari | ||
browsers = ['ChromeCanary']; | ||
|
||
// If browser does not capture in given timeout [ms], kill it | ||
// CLI --capture-timeout 5000 | ||
captureTimeout = 50000; | ||
|
||
// Auto run tests on start (when browsers are captured) and exit | ||
// CLI --single-run --no-single-run | ||
singleRun = true; | ||
|
||
// report which specs are slower than 500ms | ||
// CLI --report-slower-than 500 | ||
reportSlowerThan = 500; | ||
|
||
// compile coffee scripts | ||
preprocessors = { | ||
}; | ||
|
||
plugins = [ | ||
'karma-mocha', | ||
'karma-chrome-launcher', | ||
'karma-firefox-launcher', | ||
'karma-script-launcher', | ||
'karma-crbot-reporter' | ||
] |
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,5 @@ | ||
mocha.setup({ | ||
ui:'tdd', | ||
ignoreLeaks: true | ||
}); | ||
var assert = chai.assert; |
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,99 @@ | ||
## Expression Syntax | ||
|
||
An ExpressionSyntax is provided as an example of a syntax which is implemented in script using the template element's [Syntax API](https://github.com/Polymer/mdv/blob/master/docs/syntax_api.md). It allows the use of named scopes within template `bind` and `repeat` and simple inline expressions within bindings. | ||
|
||
* Include the implementation: | ||
|
||
```HTML | ||
<script src="util/expression_syntax.js"></script> | ||
``` | ||
|
||
* Register the syntax for use on the template element (sub-templates will inherit its use). | ||
|
||
```JavaScript | ||
templateElement.bindingDelegate = new ExpressionSyntax(); | ||
``` | ||
|
||
* Use the syntax in your templates | ||
|
||
```HTML | ||
<template bind> | ||
<template repeat="{{ user in users }}"> | ||
{{ user.name }} <template if="{{ user.age >= 21 }}"> Can have a drink!</template> | ||
</template> | ||
</template> | ||
``` | ||
|
||
## Features | ||
|
||
### Inline expressions | ||
|
||
The ExpressionSyntax allows for inline expressions within bindings which support a strict subset of the JavaScript language. In order to use this feature, it's important to understand its behavior and limitations: | ||
|
||
* The goal for inline expressions is to allow the expression of simple value concepts and relationships. It is generally bad practice to put complex logic into your HTML (view). | ||
* Expressions are never run (e.g. eval) as page script. They cannot access any global state (e.g. window). They are parsed and converted to a simple interpretted form which is provided the present values of paths contained in the expression. | ||
|
||
The specific subset of JavaScript which is supported is: | ||
|
||
* Identifiers & paths, e.g. 'foo', 'foo.bar.baz'. These values are treated as relative to the local model, extracted, observed for changes and cause the expression to be re-evaluated if one or more has changed. | ||
* The logical not operator: ! | ||
* The unary operators: + (Convert to Number), - (Convert to Number and negate). | ||
* The binary operators: + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulo). | ||
* Comparators: < (less than), > (greater than), <= (less than or equal), >= (greater then or equal), == (equal), != (not equal), === (identity equally), !== (identity inequality) | ||
* Logical comparators: || (or), && (and) | ||
* Conditional statements: ?. e.g. 'a ? b : c'. | ||
* Grouping (parenthesis): e.g. '(a + b) * (c + d)' | ||
* Literal values: e.g. numbers, strings, null, undefined. Note that escaped strings and non-decimal numbers are not supported. | ||
* Array & Object initializers: e.g. '[foo, 1]', '{ id: 1, foo: bar }' | ||
* Labeled statements: e.g. 'foo: bar.baz; bat: boo > 2' | ||
|
||
When an expression is used within a mustach (`{{` `}}`), it is parsed. The expression should be a single statement, or multiple labeled statements. | ||
|
||
* If the result is a single unlabeled statement, whenever the value of one or more paths in the expression change, the value of the expression re-evaluated and the result inserted as the value of the mustache. e.g. | ||
|
||
```HTML | ||
<div>Jill has {{ daughter.children.length + son.children.length }} grandchildren</div> | ||
``` | ||
|
||
* If the result is one or more labeled statements, the value of the mustache will include the set of space-separated label identifiers whose corresponding expressions are truthy. e.g. | ||
|
||
```HTML | ||
<div class="{{ active: user.selected; big: user.type == 'super' }}"> | ||
``` | ||
|
||
### Named scope | ||
|
||
Named scopes are the solution to wanting to reference a model value from an "outer" model "scope". e.g. | ||
|
||
```HTML | ||
<template repeat="{{ user in users }}"> | ||
{{ user.name }} | ||
<template repeat="{{ file in user.files }}"> | ||
{{ user.name }} owners {{ file.name }} | ||
</template> | ||
</template> | ||
``` | ||
|
||
The scope naming is available (but optional) inside `template` `bind` and `repeat` directives. | ||
|
||
* `bind` syntax: `<template bind="{{ expression as identifier }}">` | ||
* `repeat` syntax: `<template repeat="{{ identifier in expression }}">` | ||
|
||
Note that `expression` can be a simple identifier, a path or a full expression (including Object and Array literals). | ||
|
||
Within a `template` instance produced by a template using a named scope, all ancestor scopes are visible, up-to and including the first ancestor NOT using a named scope. e.g. | ||
|
||
```HTML | ||
<template bind="{{ foo as foo }}"> | ||
<!-- foo.* available --> | ||
<template bind="{{ foo.bar as bar }}"> | ||
<!-- foo.* & bar.* available --> | ||
<template bind="{{ bar.bat }}"> | ||
<!-- only properties of bat are available --> | ||
<template bind="{{ boo as bot }}"> | ||
<!-- bot.* and properties of bat are available. NOT foo.* or bar.* --> | ||
</template> | ||
</template> | ||
</template> | ||
</template> | ||
``` |
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
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
Oops, something went wrong.