Skip to content
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

8/1 master -> stable #223

Merged
merged 29 commits into from
Aug 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b3727b3
remove build log
dfreedm Jul 11, 2013
448c4d7
Throw a useful error for deprecated use of Polymer.register
dfreedm Jul 16, 2013
9a0879f
native `createdCallback` fires immediately on element creation, befor…
Jul 17, 2013
f163593
platform now automatically makes sure shadowRoot has: .olderShadowRoo…
sorvell Jul 23, 2013
7045c9a
Accept a call to Polymer(name, prototype /*optional */ ) with optiona…
sorvell Jul 23, 2013
9cfa5e7
update tests to account for recent changes.
sorvell Jul 23, 2013
16266cb
Add 'noscript' to instance attributes black list.
sorvell Jul 23, 2013
f50c6f8
Allow a prototypal value of null to indicate that a property should b…
sorvell Jul 24, 2013
318a260
Addresses issue #188:
sorvell Jul 24, 2013
bbd887b
document blacklist (a bit)
Jul 24, 2013
20c622c
fix grunt file
Jul 27, 2013
dcce1d4
repair references in test: < shadow >.olderShadowRoot removed in favo…
sorvell Jul 29, 2013
e4dd36f
make test pass in the presence of ShadowDOMPolyfill since these featu…
sorvell Jul 29, 2013
c039698
making timing more lenient for CustomElements/MO polyfill
sorvell Jul 29, 2013
477a5cf
Make tests call CustomElements.takeRecords to ensure they work in IE …
sorvell Jul 30, 2013
d40dc98
super requires __proto__. Simulate this in *test* where unsupported.
sorvell Jul 30, 2013
5ab7b2f
Temporarily remove failing mdv syntax test, blocked on https://github…
sorvell Jul 30, 2013
62eb34b
Improve IE compatibility by ensuring the __proto__ chain always exists.
sorvell Jul 30, 2013
7bcf366
Remove deprecated files.
sorvell Jul 30, 2013
c1ac385
Use raw prototype traversal to ensure compatibility with platforms wi…
sorvell Jul 30, 2013
fae6f96
Ensure prototype traversal can be done during desugaring.
sorvell Jul 30, 2013
62e0233
Polymer supports entered/leftDocument, note that inserted/removed are…
sorvell Jul 31, 2013
c65e5fc
ensure elements used for testing are uniquely named (elements cannot …
sorvell Jul 31, 2013
b8d7654
remove use of noscript.
sorvell Jul 31, 2013
9d2beb8
remove noscript feature for now
sorvell Jul 31, 2013
92dbcaf
correct test so that it includes proper scripts
sorvell Jul 31, 2013
44b30e1
update sheet-main-doc test.
sorvell Aug 1, 2013
0f96e27
revert element-script test: currently passes under polyfill and not n…
sorvell Aug 1, 2013
6e0338c
do not consider null valued prototype an indicator that a property sh…
sorvell Aug 1, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO NPM INSTALL
@call npm install
@ECHO .
@ECHO GRUNT
@call grunt
41 changes: 0 additions & 41 deletions build.log

This file was deleted.

10 changes: 5 additions & 5 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ module.exports = function(grunt) {
Polymer = [
"polymer.js",
"boot.js",
"shimStyling.js",
"lib/lang.js",
"lib/dom.js",
"lib/deserialize.js",
"lib/job.js",
"lib/dom.js",
"lib/super.js",
"lib/deserialize.js",
"api.js",
"instance/utils.js",
"instance/events.js",
"instance/properties.js",
"instance/attributes.js",
"instance/properties.js",
"instance/mdv.js",
"instance/base.js",
"instance/styles.js",
Expand All @@ -38,7 +37,8 @@ module.exports = function(grunt) {
"declaration/events.js",
"declaration/properties.js",
"declaration/attributes.js",
"declaration/polymer-element.js"
"declaration/polymer-element.js",
"deprecated.js"
].map(function(n) {
return "src/" + n;
});
Expand Down
5 changes: 3 additions & 2 deletions polymer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var modules = [
"api.js",
"instance/utils.js",
"instance/events.js",
"instance/properties.js",
"instance/attributes.js",
"instance/properties.js",
"instance/mdv.js",
"instance/base.js",
"instance/styles.js",
Expand All @@ -31,7 +31,8 @@ var modules = [
"declaration/events.js",
"declaration/properties.js",
"declaration/attributes.js",
"declaration/polymer-element.js"
"declaration/polymer-element.js",
"deprecated.js"
].map(function(n) {
return "src/" + n;
}));
Expand Down
3 changes: 2 additions & 1 deletion src/declaration/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
isInstanceAttribute: function(name) {
return !this.blackList[name] && name.slice(0,3) !== 'on-';
},
blackList: {name: 1, 'extends': 1, constructor: 1}
// do not clone these attributes onto instances
blackList: {name: 1, 'extends': 1, constructor: 1, noscript: 1}
};

// add ATTRIBUTES symbol to blacklist
Expand Down
42 changes: 39 additions & 3 deletions src/declaration/polymer-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,62 @@
var extend = Polymer.extend;
var apis = scope.api.declaration;

var deferred = {};

// imperative implementation: Polymer()

// maps tag names to prototypes
var registry = {};

// register an 'own' prototype for tag `name`
function element(name, prototype) {
registry[name] = prototype;
registry[name] = prototype || {};
if (deferred[name]) {
deferred[name].define();
}
}

// returns a prototype that chains to <tag> or HTMLElement
function generatePrototype(tag) {
return Object.create(HTMLElement.getPrototypeForTag(tag));
}

// On platforms that do not support __proto__ (IE10), the prototype chain
// of a custom element is simulated via installation of __proto__.
// Although custom elements manages this, we install it here so it's
// available during desuaring.
function ensurePrototypeTraversal(prototype) {
if (!Object.__proto__) {
var ancestor = Object.getPrototypeOf(prototype);
prototype.__proto__ = ancestor;
if (scope.isBase(ancestor)) {
ancestor.__proto__ = Object.getPrototypeOf(ancestor);
}
}
}

// declarative implementation: <polymer-element>

var prototype = generatePrototype();
extend(prototype, {
// custom element processing
// TODO(sjmiles): temporary BC
readyCallback: function() {
this._createdCallback();
},
createdCallback: function() {
this._createdCallback();
},
// custom element processing
_createdCallback: function() {
// fetch our element name
var name = this.getAttribute('name');
if (registry[name]) {
this.define();
} else {
deferred[name] = this;
}
},
define: function() {
// fetch our element name
var name = this.getAttribute('name');
// fetch our extendee name
Expand All @@ -45,6 +80,7 @@
// Potentially remove when spec bug is addressed.
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=21407
this.addResolvePathApi();
ensurePrototypeTraversal(this.prototype);
// declarative features
this.desugar();
// under ShadowDOMPolyfill, transforms to approximate missing CSS features
Expand Down Expand Up @@ -111,7 +147,7 @@
// make a fresh object that inherits from a prototype object
inheritObject: function(prototype, name) {
// copy inherited properties onto a new object
prototype[name] = extend({}, prototype.__proto__[name]);
prototype[name] = extend({}, Object.getPrototypeOf(prototype)[name]);
},
// register 'prototype' to custom element 'name', store constructor
register: function(name) {
Expand Down
14 changes: 14 additions & 0 deletions src/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2013 The Polymer Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/

// NOTE: put deprecated methods here that throw a useful error
Polymer.register = function(context) {
if (context != window) {
// context is the <element> here, with a name attribute
var name = context.getAttribute('name');
throw new Error('Polymer.register is deprecated in declaration of ' + name + '. Please see http://www.polymer-project.org/getting-started.html');
}
};
13 changes: 13 additions & 0 deletions src/instance/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@
// convert representation of 'stringValue' based on type of 'defaultValue'
deserializeValue: function(stringValue, defaultValue) {
return scope.deserializeValue(stringValue, defaultValue);
},
serializeValue: function(value) {
if (typeof value != 'object' && value !== undefined) {
return value;
}
},
propertyToAttribute: function(name) {
if (Object.keys(this[PUBLISHED]).indexOf(name) >= 0) {
var serializedValue = this.serializeValue(this[name]);
if (serializedValue !== undefined) {
this.setAttribute(name, serializedValue);
}
}
}
};

Expand Down
55 changes: 45 additions & 10 deletions src/instance/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
// user entry point for constructor-like initialization
ready: function() {
},
// system entry point, do not override
// TODO(sjmiles): temporary BC
readyCallback: function() {
this._createdCallback();
},
createdCallback: function() {
this._createdCallback();
},
// system entry point, do not override
_createdCallback: function() {
//this.style.display = 'inline-block';
// install property observers
// do this first so we can observe changes during initialization
Expand All @@ -31,10 +38,44 @@
// bindings will self destruct after a short time; this is
// necessary to make elements collectable as garbage
// when polyfilling Object.observe
this.asyncUnbindAll();
//this.asyncUnbindAll();
// user initialization
this.ready();
},
insertedCallback: function() {
this._enteredDocumentCallback();
},
enteredDocumentCallback: function() {
this._enteredDocumentCallback();
},
_enteredDocumentCallback: function() {
this.cancelUnbindAll(true);
// TODO(sorvell): bc
if (this.inserted) {
this.inserted();
}
// invoke user action
if (this.enteredDocument) {
this.enteredDocument();
}
},
removedCallback: function() {
this._leftDocumentCallback();
},
leftDocumentCallback: function() {
this._leftDocumentCallback();
},
_leftDocumentCallback: function() {
this.asyncUnbindAll();
// TODO(sorvell): bc
if (this.removed) {
this.removed();
}
// invoke user action
if (this.leftDocument) {
this.leftDocument();
}
},
// recursive ancestral <element> initialization, oldest first
parseElements: function(p) {
if (p && p.element) {
Expand All @@ -57,14 +98,9 @@
var elderRoot = this.shadowRoot;
// make a shadow root
var root = this.createShadowRoot();
// memoize the elder root
root.olderShadowRoot = elderRoot;
// migrate flag(s)
root.applyAuthorStyles = this.applyAuthorStyles;
root.resetStyleInheritance = this.resetStyleInheritance;
// TODO(sorvell): host not set per spec; we set it for convenience
// so we can traverse from root to host.
root.host = this;
// stamp template
// which includes parsing and applying MDV bindings before being
// inserted (to avoid {{}} in attribute values)
Expand All @@ -74,8 +110,6 @@
root.appendChild(dom);
// perform post-construction initialization tasks on shadow root
this.shadowRootReady(root, template);
// watch future changes to shadow root
CustomElements.watchShadow(this);
// return the created shadow root
return root;
}
Expand All @@ -100,7 +134,8 @@
};
}
},
attributeChangedCallback: function() {
attributeChangedCallback: function(name, oldValue) {
this.attributeToProperty(name, this.getAttribute(name));
if (this.attributeChanged) {
this.attributeChanged.apply(this, arguments);
}
Expand Down
14 changes: 0 additions & 14 deletions src/instance/mdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@
}
});
}
},
insertedCallback: function() {
this.cancelUnbindAll(true);
// invoke user 'inserted'
if (this.inserted) {
this.inserted();
}
},
removedCallback: function() {
this.asyncUnbindAll();
// invoke user 'removed'
if (this.removed) {
this.removed();
}
}
};

Expand Down
7 changes: 6 additions & 1 deletion src/instance/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// magic words

var OBSERVE_SUFFIX = 'Changed';

var PUBLISHED = scope.api.instance.attributes.PUBLISHED;

// element api

Expand Down Expand Up @@ -53,10 +55,13 @@
unregisterObservers(this);
},
// property should be observed if it has an observation callback
// or if it is published
shouldObserveProperty: function(name) {
return Boolean(this[name + OBSERVE_SUFFIX]);
return Boolean(this[name + OBSERVE_SUFFIX] ||
Object.keys(this[PUBLISHED]).indexOf(name) >= 0);
},
dispatchPropertyChange: function(name, oldValue) {
this.propertyToAttribute(name);
invoke.call(this, name + OBSERVE_SUFFIX, [oldValue]);
}
};
Expand Down
10 changes: 8 additions & 2 deletions src/instance/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
var scope = this.findStyleController();
if (scope && !this.scopeHasElementStyle(scope, STYLE_CONTROLLER_SCOPE)) {
// allow inherited controller styles
var proto = Object.getPrototypeOf(this), cssText = '';
var proto = getPrototypeOf(this), cssText = '';
while (proto && proto.element) {
cssText += proto.element.cssTextForScope(STYLE_CONTROLLER_SCOPE);
proto = Object.getPrototypeOf(proto);
proto = getPrototypeOf(proto);
}
if (cssText) {
var style = this.element.cssTextToScopeStyle(cssText,
Expand Down Expand Up @@ -73,6 +73,12 @@
}
}
};

// NOTE: use raw prototype traversal so that we ensure correct traversal
// on platforms where the protoype chain is simulated via __proto__ (IE10)
function getPrototypeOf(prototype) {
return prototype.__proto__;
}

// exports

Expand Down
Loading