Skip to content

Commit

Permalink
Merge branch 'master' into ready-if-defaultView
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 17, 2013
2 parents 247dbb8 + 9ff1a04 commit 6180e9a
Show file tree
Hide file tree
Showing 42 changed files with 495 additions and 378 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

16 changes: 12 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and m

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

1. Setup Grunt: `sudo npm install -g grunt-cli`
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 -b master --recursive
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

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

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

git checkout master
1. Test your change
> in the repo you've made changes to, run the tests:
cd $REPO
npm install
grunt test

1. Commit your code and make a pull request.

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

Expand Down
41 changes: 21 additions & 20 deletions conf/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
module.exports = function(karma) {
var common = require('../tools/test/karma-common.conf.js');
var common = require('../../tools/test/karma-common.conf.js');
karma.set(common.mixin_common_opts(karma, {
// base path, that will be used to resolve files and exclude
basePath: '../../',

// list of files / patterns to load in the browser
files: [
'polymer/tools/test/mocha-htmltest.js',
'tools/test/mocha-htmltest.js',
'polymer/conf/mocha.conf.js',
'polymer/node_modules/chai/chai.js',
'polymer/polymer.js',
'polymer/test/js/*.js',
{pattern: 'platform/*.js', included: false},
{pattern: 'platform/tools/**/*.js', included: false},
{pattern: 'platform/platform.*', included: false},
{pattern: 'platform/test/**/*.html', included: false},
{pattern: 'platform/test/**/*.js', included: false},
{pattern: 'platform/src/*.js', included: false},
{pattern: 'CustomElements/custom-elements.js', included: false},
{pattern: 'CustomElements/MutationObservers/*.js', included: false},
{pattern: 'CustomElements/custom-elements.js', included: false},
{pattern: 'CustomElements/src/*.js', included: false},
{pattern: 'HTMLImports/html-imports.js', included: false},
{pattern: 'HTMLImports/src/*', included: false},
{pattern: 'NodeBind/src/*.js', included: false},
{pattern: 'PointerEvents/pointerevents.js', included: false},
{pattern: 'PointerEvents/src/*.js', included: false},
{pattern: 'PointerGestures/pointergestures.js', included: false},
{pattern: 'PointerGestures/src/*.js', included: false},
{pattern: 'ShadowDOM/shadowdom.js', included: false},
{pattern: 'ShadowDOM/src/**/*.js', included: false},
{pattern: 'observe-js/src/*.js', included: false},
{pattern: 'observe-js/util/*.js', included: false},
{pattern: 'NodeBind/src/*.js', included: false},
{pattern: 'TemplateBinding/load.js', included: false},
{pattern: 'TemplateBinding/src/*.js', included: false},
{pattern: 'TemplateBinding/src/*.css', included: false},
{pattern: 'TemplateBinding/src/*.js', included: false},
{pattern: 'WeakMap/weakmap.js', included: false},
{pattern: 'observe-js/src/*.js', included: false},
{pattern: 'observe-js/util/*.js', included: false},
{pattern: 'platform/*.js', included: false},
{pattern: 'platform/platform.*', included: false},
{pattern: 'platform/src/*.js', included: false},
{pattern: 'platform/test/**/*.html', included: false},
{pattern: 'platform/test/**/*.js', included: false},
{pattern: 'platform/tools/**/*.js', included: false},
{pattern: 'polymer-expressions/src/*.js', included: false},
{pattern: 'polymer-expressions/third_party/**/*.js', included: false},
{pattern: 'PointerEvents/pointerevents.js', included: false},
{pattern: 'PointerEvents/src/*.js', included: false},
{pattern: 'PointerGestures/pointergestures.js', included: false},
{pattern: 'PointerGestures/src/*.js', included: false},
{pattern: 'polymer/tools/**/*.js', included: false},
{pattern: 'polymer/src/**/*.js', included: false},
{pattern: 'polymer/test/**/*.html', included: false},
{pattern: 'polymer/test/**/*.css', included: false},
{pattern: 'polymer/test/**/*.js', included: false}
{pattern: 'polymer/test/**/*.html', included: false},
{pattern: 'polymer/test/**/*.js', included: false},
{pattern: 'tools/**/*.js', included: false}
]
}));
};
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = function(grunt) {
outdir: 'docs',
linkNatives: 'true',
tabtospace: 2,
themedir: 'tools/doc/themes/bootstrap'
themedir: '../tools/doc/themes/bootstrap'
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Polymer",
"version": "0.0.20130905",
"version": "0.0.20130912",
"devDependencies": {
"mocha": "*",
"chai": "*",
Expand Down
2 changes: 1 addition & 1 deletion polymer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var src = script.attributes.src.value;
var basePath = src.slice(0, src.indexOf(thisFile));

if (!window.PolymerLoader) {
var path = basePath + 'tools/loader/loader.js';
var path = basePath + '../tools/loader/loader.js';
document.write('<script src="' + path + '"></script>');
}
document.write('<script>PolymerLoader.load("' + scopeName + '")</script>');
Expand Down
80 changes: 21 additions & 59 deletions src/declaration/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,42 @@
*/
(function(scope) {

// imports

var api = scope.api.instance.attributes;

var PUBLISHED = api.PUBLISHED;
var INSTANCE_ATTRIBUTES = api.INSTANCE_ATTRIBUTES;

// magic words

var PUBLISH = 'publish';
var ATTRIBUTES = 'attributes';
var ATTRIBUTES_ATTRIBUTE = 'attributes';

// attributes api

var attributes = {
inheritAttributesObjects: function(prototype) {
this.inheritObject(prototype, PUBLISHED);
this.inheritObject(prototype, INSTANCE_ATTRIBUTES);
// chain our lower-cased publish map to the inherited version
this.inheritObject(prototype, 'publishLC');
// chain our instance attributes map to the inherited version
this.inheritObject(prototype, '_instanceAttributes');
},
parseAttributes: function() {
this.publishAttributes(this.prototype);
this.publishProperties(this.prototype);
this.accumulateInstanceAttributes();
},
publishAttributes: function(prototype) {
// get published properties
var published = prototype[PUBLISHED];
// merge attribute names from 'attributes' attribute
var attributes = this.getAttribute(ATTRIBUTES);
publishAttributes: function(prototype, base) {
// merge names from 'attributes' attribute
var attributes = this.getAttribute(ATTRIBUTES_ATTRIBUTE);
if (attributes) {
// attributes='a b c' or attributes='a,b,c'
// get properties to publish
var publish = prototype.publish || (prototype.publish = {});
// names='a b c' or names='a,b,c'
var names = attributes.split(attributes.indexOf(',') >= 0 ? ',' : ' ');
// record each name for publishing
names.forEach(function(p) {
p = p.trim();
if (p && !(p in published)) {
published[p] = null;
for (var i=0, l=names.length, n; i<l; i++) {
// remove excess ws
n = names[i].trim();
// do not override explicit entries
if (publish[n] === undefined && base[n] === undefined) {
publish[n] = null;
}
});
}
// install 'attributes' as properties on the prototype,
// but don't override
Object.keys(published).forEach(function(p) {
if (!(p in prototype)) {
prototype[p] = published[p];
}
});
},
publishProperties: function(prototype) {
this.publishPublish(prototype);
},
publishPublish: function(prototype) {
// process only the PUBLISH block on this prototype, not the chain
if (!prototype.hasOwnProperty(PUBLISH)) {
return;
}
// acquire properties published imperatively
var imperative = prototype[PUBLISH];
if (imperative) {
// install imperative properties, overriding defaults
Object.keys(imperative).forEach(function(p) {
prototype[p] = imperative[p];
});
// combine with other published properties
Platform.mixin(
prototype[PUBLISHED],
imperative
);
}
},
// record clonable attributes from <element>
accumulateInstanceAttributes: function() {
// inherit instance attributes
var clonable = this.prototype[INSTANCE_ATTRIBUTES];
var clonable = this.prototype._instanceAttributes;
// merge attributes from element
this.attributes.forEach(function(a) {
if (this.isInstanceAttribute(a.name)) {
Expand All @@ -93,11 +55,11 @@
blackList: {name: 1, 'extends': 1, constructor: 1, noscript: 1}
};

// add ATTRIBUTES symbol to blacklist
attributes.blackList[ATTRIBUTES] = 1;
// add ATTRIBUTES_ATTRIBUTE to the blacklist
attributes.blackList[ATTRIBUTES_ATTRIBUTE] = 1;

// exports

scope.api.declaration.attributes = attributes;

})(Polymer);
63 changes: 11 additions & 52 deletions src/declaration/polymer-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@
// finalizing elements in the main document
if (document.contains(this)) {
whenImportsLoaded(function() {
this.register(this.name, extendee);
this._register(extendee);
}.bind(this));
} else {
this.register(this.name, extendee);
this._register(extendee);
}
},
_register: function(extendee) {
//console.group('registering', this.name);
this.register(this.name, extendee);
//console.groupEnd();
// subclasses may now register themselves
notifySuper(this.name);
},
waitingForPrototype: function(name) {
if (!getRegisteredPrototype(name)) {
// then wait for a prototype
Expand Down Expand Up @@ -87,60 +94,12 @@
return true;
}
}
},
register: function(name, extendee) {
// build prototype combining extendee, Polymer base, and named api
this.prototype = this.generateCustomPrototype(name, extendee);
// backref
this.prototype.element = this;
// TODO(sorvell): install a helper method this.resolvePath to aid in
// setting resource paths. e.g.
// this.$.image.src = this.resolvePath('images/foo.png')
// Potentially remove when spec bug is addressed.
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=21407
this.addResolvePathApi();
// declarative features
this.desugar();
// under ShadowDOMPolyfill, transforms to approximate missing CSS features
if (window.ShadowDOMPolyfill) {
Platform.ShadowCSS.shimStyling(this.templateContent(), name, extendee);
}
// register our custom element
this.registerPrototype(name);
// reference constructor in a global named by 'constructor' attribute
this.publishConstructor();
// subclasses may now register themselves
notifySuper(name);
},
// implement various declarative features
desugar: function(prototype) {
// parse `attribute` attribute and `publish` object
this.parseAttributes();
// parse on-* delegates declared on `this` element
this.parseHostEvents();
// parse on-* delegates declared in templates
this.parseLocalEvents();
// install external stylesheets as if they are inline
this.installSheets();
// allow custom element access to the declarative context
if (this.prototype.registerCallback) {
this.prototype.registerCallback(this);
}
// cache the list of custom prototype names for faster reflection
this.cacheProperties();
},
// if a named constructor is requested in element, map a reference
// to the constructor to the given symbol
publishConstructor: function() {
var symbol = this.getAttribute('constructor');
if (symbol) {
window[symbol] = this.ctor;
}
}
});

// semi-pluggable APIs
// TODO(sjmiles): should be fully pluggable
// TODO(sjmiles): should be fully pluggable (aka decoupled, currently
// the various plugins are allowed to depend on each other directly)
Object.keys(apis).forEach(function(n) {
extend(prototype, apis[n]);
});
Expand Down
Loading

0 comments on commit 6180e9a

Please sign in to comment.