Skip to content

Commit 6180e9a

Browse files
committed
Merge branch 'master' into ready-if-defaultView
2 parents 247dbb8 + 9ff1a04 commit 6180e9a

42 files changed

Lines changed: 495 additions & 378 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,29 @@ Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and m
2121

2222
Here's an easy guide that should get you up and running:
2323

24+
1. Setup Grunt: `sudo npm install -g grunt-cli`
2425
1. Fork the project on github and pull down your copy.
2526
> replace the {{ username }} with your username and {{ repository }} with the repository name
2627
27-
git clone git@github.com:{{ username }}/{{ repository }}.git -b master --recursive
28+
git clone git@github.com:{{ username }}/{{ repository }}.git --recursive
2829

2930
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:
3031

3132
git submodule init
3233
git submodule update
3334

34-
Adding `-b master` is a shorthand to checkout the `master` branch. If you include it, skip step 2.
35+
Download and run the `pull-all.sh` script to install the sibling dependencies.
3536

36-
2. Development happens on the `master` branch. Get yourself on it!
37+
git clone git://github.com/Polymer/tools.git && tools/bin/pull-all.sh
3738

38-
git checkout master
39+
1. Test your change
40+
> in the repo you've made changes to, run the tests:
41+
42+
cd $REPO
43+
npm install
44+
grunt test
45+
46+
1. Commit your code and make a pull request.
3947

4048
That's it for the one time setup. Now you're ready to make a change.
4149

conf/karma.conf.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
module.exports = function(karma) {
2-
var common = require('../tools/test/karma-common.conf.js');
2+
var common = require('../../tools/test/karma-common.conf.js');
33
karma.set(common.mixin_common_opts(karma, {
44
// base path, that will be used to resolve files and exclude
55
basePath: '../../',
66

77
// list of files / patterns to load in the browser
88
files: [
9-
'polymer/tools/test/mocha-htmltest.js',
9+
'tools/test/mocha-htmltest.js',
1010
'polymer/conf/mocha.conf.js',
1111
'polymer/node_modules/chai/chai.js',
1212
'polymer/polymer.js',
1313
'polymer/test/js/*.js',
14-
{pattern: 'platform/*.js', included: false},
15-
{pattern: 'platform/tools/**/*.js', included: false},
16-
{pattern: 'platform/platform.*', included: false},
17-
{pattern: 'platform/test/**/*.html', included: false},
18-
{pattern: 'platform/test/**/*.js', included: false},
19-
{pattern: 'platform/src/*.js', included: false},
20-
{pattern: 'CustomElements/custom-elements.js', included: false},
2114
{pattern: 'CustomElements/MutationObservers/*.js', included: false},
15+
{pattern: 'CustomElements/custom-elements.js', included: false},
2216
{pattern: 'CustomElements/src/*.js', included: false},
2317
{pattern: 'HTMLImports/html-imports.js', included: false},
2418
{pattern: 'HTMLImports/src/*', included: false},
19+
{pattern: 'NodeBind/src/*.js', included: false},
20+
{pattern: 'PointerEvents/pointerevents.js', included: false},
21+
{pattern: 'PointerEvents/src/*.js', included: false},
22+
{pattern: 'PointerGestures/pointergestures.js', included: false},
23+
{pattern: 'PointerGestures/src/*.js', included: false},
2524
{pattern: 'ShadowDOM/shadowdom.js', included: false},
2625
{pattern: 'ShadowDOM/src/**/*.js', included: false},
27-
{pattern: 'observe-js/src/*.js', included: false},
28-
{pattern: 'observe-js/util/*.js', included: false},
29-
{pattern: 'NodeBind/src/*.js', included: false},
3026
{pattern: 'TemplateBinding/load.js', included: false},
31-
{pattern: 'TemplateBinding/src/*.js', included: false},
3227
{pattern: 'TemplateBinding/src/*.css', included: false},
28+
{pattern: 'TemplateBinding/src/*.js', included: false},
29+
{pattern: 'WeakMap/weakmap.js', included: false},
30+
{pattern: 'observe-js/src/*.js', included: false},
31+
{pattern: 'observe-js/util/*.js', included: false},
32+
{pattern: 'platform/*.js', included: false},
33+
{pattern: 'platform/platform.*', included: false},
34+
{pattern: 'platform/src/*.js', included: false},
35+
{pattern: 'platform/test/**/*.html', included: false},
36+
{pattern: 'platform/test/**/*.js', included: false},
37+
{pattern: 'platform/tools/**/*.js', included: false},
3338
{pattern: 'polymer-expressions/src/*.js', included: false},
3439
{pattern: 'polymer-expressions/third_party/**/*.js', included: false},
35-
{pattern: 'PointerEvents/pointerevents.js', included: false},
36-
{pattern: 'PointerEvents/src/*.js', included: false},
37-
{pattern: 'PointerGestures/pointergestures.js', included: false},
38-
{pattern: 'PointerGestures/src/*.js', included: false},
39-
{pattern: 'polymer/tools/**/*.js', included: false},
4040
{pattern: 'polymer/src/**/*.js', included: false},
41-
{pattern: 'polymer/test/**/*.html', included: false},
4241
{pattern: 'polymer/test/**/*.css', included: false},
43-
{pattern: 'polymer/test/**/*.js', included: false}
42+
{pattern: 'polymer/test/**/*.html', included: false},
43+
{pattern: 'polymer/test/**/*.js', included: false},
44+
{pattern: 'tools/**/*.js', included: false}
4445
]
4546
}));
4647
};

gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function(grunt) {
7878
outdir: 'docs',
7979
linkNatives: 'true',
8080
tabtospace: 2,
81-
themedir: 'tools/doc/themes/bootstrap'
81+
themedir: '../tools/doc/themes/bootstrap'
8282
}
8383
}
8484
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Polymer",
3-
"version": "0.0.20130905",
3+
"version": "0.0.20130912",
44
"devDependencies": {
55
"mocha": "*",
66
"chai": "*",

polymer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var src = script.attributes.src.value;
5252
var basePath = src.slice(0, src.indexOf(thisFile));
5353

5454
if (!window.PolymerLoader) {
55-
var path = basePath + 'tools/loader/loader.js';
55+
var path = basePath + '../tools/loader/loader.js';
5656
document.write('<script src="' + path + '"></script>');
5757
}
5858
document.write('<script>PolymerLoader.load("' + scopeName + '")</script>');

src/declaration/attributes.js

Lines changed: 21 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,42 @@
55
*/
66
(function(scope) {
77

8-
// imports
9-
10-
var api = scope.api.instance.attributes;
11-
12-
var PUBLISHED = api.PUBLISHED;
13-
var INSTANCE_ATTRIBUTES = api.INSTANCE_ATTRIBUTES;
14-
158
// magic words
169

17-
var PUBLISH = 'publish';
18-
var ATTRIBUTES = 'attributes';
10+
var ATTRIBUTES_ATTRIBUTE = 'attributes';
1911

2012
// attributes api
2113

2214
var attributes = {
2315
inheritAttributesObjects: function(prototype) {
24-
this.inheritObject(prototype, PUBLISHED);
25-
this.inheritObject(prototype, INSTANCE_ATTRIBUTES);
16+
// chain our lower-cased publish map to the inherited version
17+
this.inheritObject(prototype, 'publishLC');
18+
// chain our instance attributes map to the inherited version
19+
this.inheritObject(prototype, '_instanceAttributes');
2620
},
27-
parseAttributes: function() {
28-
this.publishAttributes(this.prototype);
29-
this.publishProperties(this.prototype);
30-
this.accumulateInstanceAttributes();
31-
},
32-
publishAttributes: function(prototype) {
33-
// get published properties
34-
var published = prototype[PUBLISHED];
35-
// merge attribute names from 'attributes' attribute
36-
var attributes = this.getAttribute(ATTRIBUTES);
21+
publishAttributes: function(prototype, base) {
22+
// merge names from 'attributes' attribute
23+
var attributes = this.getAttribute(ATTRIBUTES_ATTRIBUTE);
3724
if (attributes) {
38-
// attributes='a b c' or attributes='a,b,c'
25+
// get properties to publish
26+
var publish = prototype.publish || (prototype.publish = {});
27+
// names='a b c' or names='a,b,c'
3928
var names = attributes.split(attributes.indexOf(',') >= 0 ? ',' : ' ');
4029
// record each name for publishing
41-
names.forEach(function(p) {
42-
p = p.trim();
43-
if (p && !(p in published)) {
44-
published[p] = null;
30+
for (var i=0, l=names.length, n; i<l; i++) {
31+
// remove excess ws
32+
n = names[i].trim();
33+
// do not override explicit entries
34+
if (publish[n] === undefined && base[n] === undefined) {
35+
publish[n] = null;
4536
}
46-
});
47-
}
48-
// install 'attributes' as properties on the prototype,
49-
// but don't override
50-
Object.keys(published).forEach(function(p) {
51-
if (!(p in prototype)) {
52-
prototype[p] = published[p];
5337
}
54-
});
55-
},
56-
publishProperties: function(prototype) {
57-
this.publishPublish(prototype);
58-
},
59-
publishPublish: function(prototype) {
60-
// process only the PUBLISH block on this prototype, not the chain
61-
if (!prototype.hasOwnProperty(PUBLISH)) {
62-
return;
63-
}
64-
// acquire properties published imperatively
65-
var imperative = prototype[PUBLISH];
66-
if (imperative) {
67-
// install imperative properties, overriding defaults
68-
Object.keys(imperative).forEach(function(p) {
69-
prototype[p] = imperative[p];
70-
});
71-
// combine with other published properties
72-
Platform.mixin(
73-
prototype[PUBLISHED],
74-
imperative
75-
);
7638
}
7739
},
7840
// record clonable attributes from <element>
7941
accumulateInstanceAttributes: function() {
8042
// inherit instance attributes
81-
var clonable = this.prototype[INSTANCE_ATTRIBUTES];
43+
var clonable = this.prototype._instanceAttributes;
8244
// merge attributes from element
8345
this.attributes.forEach(function(a) {
8446
if (this.isInstanceAttribute(a.name)) {
@@ -93,11 +55,11 @@
9355
blackList: {name: 1, 'extends': 1, constructor: 1, noscript: 1}
9456
};
9557

96-
// add ATTRIBUTES symbol to blacklist
97-
attributes.blackList[ATTRIBUTES] = 1;
58+
// add ATTRIBUTES_ATTRIBUTE to the blacklist
59+
attributes.blackList[ATTRIBUTES_ATTRIBUTE] = 1;
9860

9961
// exports
10062

10163
scope.api.declaration.attributes = attributes;
102-
64+
10365
})(Polymer);

src/declaration/polymer-element.js

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,19 @@
4949
// finalizing elements in the main document
5050
if (document.contains(this)) {
5151
whenImportsLoaded(function() {
52-
this.register(this.name, extendee);
52+
this._register(extendee);
5353
}.bind(this));
5454
} else {
55-
this.register(this.name, extendee);
55+
this._register(extendee);
5656
}
5757
},
58+
_register: function(extendee) {
59+
//console.group('registering', this.name);
60+
this.register(this.name, extendee);
61+
//console.groupEnd();
62+
// subclasses may now register themselves
63+
notifySuper(this.name);
64+
},
5865
waitingForPrototype: function(name) {
5966
if (!getRegisteredPrototype(name)) {
6067
// then wait for a prototype
@@ -87,60 +94,12 @@
8794
return true;
8895
}
8996
}
90-
},
91-
register: function(name, extendee) {
92-
// build prototype combining extendee, Polymer base, and named api
93-
this.prototype = this.generateCustomPrototype(name, extendee);
94-
// backref
95-
this.prototype.element = this;
96-
// TODO(sorvell): install a helper method this.resolvePath to aid in
97-
// setting resource paths. e.g.
98-
// this.$.image.src = this.resolvePath('images/foo.png')
99-
// Potentially remove when spec bug is addressed.
100-
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=21407
101-
this.addResolvePathApi();
102-
// declarative features
103-
this.desugar();
104-
// under ShadowDOMPolyfill, transforms to approximate missing CSS features
105-
if (window.ShadowDOMPolyfill) {
106-
Platform.ShadowCSS.shimStyling(this.templateContent(), name, extendee);
107-
}
108-
// register our custom element
109-
this.registerPrototype(name);
110-
// reference constructor in a global named by 'constructor' attribute
111-
this.publishConstructor();
112-
// subclasses may now register themselves
113-
notifySuper(name);
114-
},
115-
// implement various declarative features
116-
desugar: function(prototype) {
117-
// parse `attribute` attribute and `publish` object
118-
this.parseAttributes();
119-
// parse on-* delegates declared on `this` element
120-
this.parseHostEvents();
121-
// parse on-* delegates declared in templates
122-
this.parseLocalEvents();
123-
// install external stylesheets as if they are inline
124-
this.installSheets();
125-
// allow custom element access to the declarative context
126-
if (this.prototype.registerCallback) {
127-
this.prototype.registerCallback(this);
128-
}
129-
// cache the list of custom prototype names for faster reflection
130-
this.cacheProperties();
131-
},
132-
// if a named constructor is requested in element, map a reference
133-
// to the constructor to the given symbol
134-
publishConstructor: function() {
135-
var symbol = this.getAttribute('constructor');
136-
if (symbol) {
137-
window[symbol] = this.ctor;
138-
}
13997
}
14098
});
14199

142100
// semi-pluggable APIs
143-
// TODO(sjmiles): should be fully pluggable
101+
// TODO(sjmiles): should be fully pluggable (aka decoupled, currently
102+
// the various plugins are allowed to depend on each other directly)
144103
Object.keys(apis).forEach(function(n) {
145104
extend(prototype, apis[n]);
146105
});

0 commit comments

Comments
 (0)