Skip to content

Commit

Permalink
Add comments. Behavior fast copy flag changed to _noAccessors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Jan 26, 2017
1 parent e588f1f commit 52ea600
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
7 changes: 7 additions & 0 deletions src/lib/base.html
Expand Up @@ -46,6 +46,7 @@
}
} else {
this._desugarBehaviors(); // abstract
// previously factor behavior call unrolled for perf
for (var i=0, b; i < this.behaviors.length; i++) {
b = this.behaviors[i];
if (b.beforeRegister) {
Expand All @@ -68,6 +69,7 @@
}
Polymer.telemetry.instanceCount++;
this.root = this;
// previously factor behavior call unrolled for perf
for (var i=0, b; i < this.behaviors.length; i++) {
b = this.behaviors[i];
if (b.created) {
Expand Down Expand Up @@ -97,6 +99,7 @@
// IFF `lazyRegister` is 'max'
if (settings.lazyRegister === 'max') {
proto._desugarBehaviors(); // abstract
// previously factor behavior call unrolled for perf
for (var i=0, b; i < proto.behaviors.length; i++) {
b = proto.behaviors[i];
if (b.beforeRegister) {
Expand All @@ -109,6 +112,7 @@
proto._finishRegisterFeatures();
}
// registration extension point
// previously factor behavior call unrolled for perf
for (var j=0, pb; j < proto.behaviors.length; j++) {
pb = proto.behaviors[j];
if (pb.registered) {
Expand All @@ -135,6 +139,7 @@
var self = this;
Polymer.RenderStatus.whenReady(function() {
self.isAttached = true;
// previously factor behavior call unrolled for perf
for (var i=0, b; i < self.behaviors.length; i++) {
b = self.behaviors[i];
if (b.attached) {
Expand All @@ -153,6 +158,7 @@
var self = this;
Polymer.RenderStatus.whenReady(function() {
self.isAttached = false;
// previously factor behavior call unrolled for perf
for (var i=0, b; i < self.behaviors.length; i++) {
b = self.behaviors[i];
if (b.detached) {
Expand All @@ -170,6 +176,7 @@
// TODO(sorvell): consider filtering out changes to host attributes
// note: this was barely measurable with 3 host attributes.
this._attributeChangedImpl(name); // abstract
// previously factor behavior call unrolled for perf
for (var i=0, b; i < this.behaviors.length; i++) {
b = this.behaviors[i];
if (b.attributeChanged) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dom-module.html
Expand Up @@ -84,7 +84,7 @@
});

Object.defineProperty(DomModule.prototype, 'constructor', {
value: DomModule, configurable: true
value: DomModule, configurable: true, writable: true
});

// NOTE: HTMLImports polyfill does not
Expand Down
27 changes: 3 additions & 24 deletions src/micro/behaviors.html
Expand Up @@ -101,10 +101,10 @@

_mixinBehavior: function(b) {
var n$ = Object.getOwnPropertyNames(b);
var skipDefine = b._skipDefineProperty;
var useAssignment = b._noAccessors;
for (var i=0, n; (i<n$.length) && (n=n$[i]); i++) {
if (!Polymer.Base._behaviorProperties[n] && !this.hasOwnProperty(n)) {
if (skipDefine) {
if (useAssignment) {
this[n] = b[n];
} else {
this.copyOwnProperty(n, b, this);
Expand All @@ -128,27 +128,6 @@
this._prepBehavior(this);
},

_doBehavior: function(name, args) {
for (var i=0; i < this.behaviors.length; i++) {
this._invokeBehavior(this.behaviors[i], name, args);
}
this._invokeBehavior(this, name, args);
},

// note: repeating logic here to avoid fn call.
_doBehaviorOnly: function(name, args) {
for (var i=0; i < this.behaviors.length; i++) {
this._invokeBehavior(this.behaviors[i], name, args);
}
},

_invokeBehavior: function(b, name, args) {
var fn = b[name];
if (fn) {
fn.apply(this, args || Polymer.nar);
}
},

_marshalBehaviors: function() {
for (var i=0; i < this.behaviors.length; i++) {
this._marshalBehavior(this.behaviors[i]);
Expand All @@ -173,7 +152,7 @@
detached: true,
attributeChanged: true,
ready: true,
_skipDefineProperty: true
_noAccessors: true
}

</script>
5 changes: 0 additions & 5 deletions test/unit/base.html
Expand Up @@ -37,11 +37,6 @@
Child._setAttributeToProperty = function() {};
Child.behaviors = [];
Child._desugarBehaviors = function() {};
Child._doBehavior = function(name, args) {
if (this[name]) {
this[name].apply(this, args || []);
}
};
instance = Object.create(Child);
// make __proto__ work on IE10.
if (!Object.__proto__) {
Expand Down

0 comments on commit 52ea600

Please sign in to comment.