Skip to content

Commit

Permalink
Merge pull request #81 from PolymerLabs/remove-v0
Browse files Browse the repository at this point in the history
Remove v0
  • Loading branch information
Steve Orvell authored Aug 24, 2016
2 parents 2b57749 + 242bd7a commit 24881c4
Show file tree
Hide file tree
Showing 43 changed files with 266 additions and 454 deletions.
15 changes: 0 additions & 15 deletions src/attributes/attribute-to-property.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@
}
}

// temporary code for simulating CE v1 attribute callbacks
simulateV1AttributeCallbacks(inst) {
if (!window.customElements) {
var attrs = inst.constructor.observedAttributes;
if (attrs) {
for (var i=0; i<attrs.length; i++) {
var attr = attrs[i];
if (inst.hasAttribute(attr)) {
inst.attributeChangedCallback(attr, null, inst.getAttribute(attr));
}
}
}
}
}

/**
* Converts a string to a typed value.
*
Expand Down
16 changes: 3 additions & 13 deletions src/compat/custom-style-container.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

constructor() {
super();
this.createdCallback();
}

createdCallback() {
if (!this._acquireStyle()) {
this._observeContent();
this._observeContent();
}
// TODO(sorvell): initialize elements in imports if necessary
// (first impl of V1 native custom elements requires this)
Expand Down Expand Up @@ -75,7 +71,7 @@

_transform(style) {
// BREAKME(kschaaf): for short-term bc, but intend to break
style.textContent =
style.textContent =
Polymer.CompatStyleUtil.normalizeCSSTextForBC(style.textContent);
Polymer.StyleLib.transformForDocument(style);
enqueueDocumentValidation();
Expand Down Expand Up @@ -104,13 +100,7 @@
documentValidationScheduled = false;
}

var name = 'custom-style-container';

if (window.customElements) {
window.customElements.define(name, CustomStyle);
} else {
CustomStyle = document.registerElement(name, CustomStyle);
}
window.customElements.define('custom-style-container', CustomStyle);

}());
</script>
13 changes: 1 addition & 12 deletions src/compat/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

constructor() {
super();
this.createdCallback();
}

createdCallback() {
var e = this.__appliedElement = (this.__appliedElement || this);
this._initialize(e);
// TODO(sorvell): initialize elements in imports if necessary
Expand Down Expand Up @@ -84,14 +80,7 @@
documentValidationScheduled = false;
}

CustomStyle.extends = 'style';
var name = 'custom-style';

if (window.customElements) {
customElements.define(name, CustomStyle);
} else {
CustomStyle = document.registerElement(name, CustomStyle);
}
customElements.define('custom-style', CustomStyle, {extends: 'style'});

})();
</script>
10 changes: 1 addition & 9 deletions src/compat/dom-module.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
this.register();
}

createdCallback() {
this.register();
}

// BREAKME(dfreedm)
_styleOutsideTemplateCheck() {
if (this.querySelector('style')) {
Expand Down Expand Up @@ -100,11 +96,7 @@
// NOTE: Safari can't deal with an ES6 style function named `import`
DomModule.prototype.import = DomModule.prototype.__import;

if (window.customElements) {
customElements.define('dom-module', DomModule);
} else {
DomModule = document.registerElement('dom-module', DomModule);
}
customElements.define('dom-module', DomModule);

// NOTE: HTMLImports polyfill does not
// block scripts on upgrading elements. However, we want to ensure that
Expand Down
10 changes: 3 additions & 7 deletions src/compat/polymer-fn.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@
if (klass.extends) {
options.extends = klass.extends;
}
if (window.customElements) {
customElements.define(klass.is, klass, options);
return klass;
} else {
return document.registerElement(klass.prototype.is, klass);
}
customElements.define(klass.is, klass, options);
return klass;
};

if (userPolymer) {
Expand All @@ -48,7 +44,7 @@
}

// TODO(sorvel): ad hoc settings...
Polymer.shadowDomV0 = Polymer.shadowDomV0 ||
Polymer.shadowDomV0 = Polymer.shadowDomV0 ||
(location.search.indexOf('shadowDomV0=true') >= 0);

})();
Expand Down
4 changes: 1 addition & 3 deletions src/elements/compat-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@
var list = [];
var c$ = this.childNodes;
for (var i=0, l=c$.length, c; (i<l) && (c=c$[i]); i++) {
// BREAKME(sorvell): remove when V0 ShadowDom support is removed.
var d$ = (c.localName === 'content') ? c.getDistributedNodes() :
((c.localName === 'slot') ? c.assignedNodes({flatten: true}) : null);
var d$ = (c.localName === 'slot') ? c.assignedNodes({flatten: true}) : null;
if (d$) {
for (var j=0; j < d$.length; j++) {
list.push(d$[j]);
Expand Down
5 changes: 2 additions & 3 deletions src/elements/element.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@
ready() {
if (!this.root) {
if (this._template) {
// BREAKME(sorvell): remove v0 support when we can...
this.root = Polymer.shadowDomV0 ? this.createShadowRoot() :
this.attachShadow({mode: 'open'});
// BREAKME(sorvell): v0 support removed
this.root = this.attachShadow({mode: 'open'});
} else {
this.root = this;
}
Expand Down
14 changes: 1 addition & 13 deletions src/templatizer/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@
class DomBind extends data.extendWithAPI(HTMLElement) {

connectedCallback() {
this.attachedCallback();
}

attachedCallback() {
this.render();
}

disconnectedCallback() {
this.detachedCallback();
}

detachedCallback() {
this._removeChildren();
}

Expand Down Expand Up @@ -74,11 +66,7 @@

}

if (window.customElements) {
customElements.define('dom-bind', DomBind);
} else {
DomBind = document.registerElement('dom-bind', DomBind);
}
customElements.define('dom-bind', DomBind);

})();

Expand Down
3 changes: 1 addition & 2 deletions test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
}, []);
}

// suites = combinations(suites, [['', 'shadowDomV0=true'], ['wc-ce=v0', 'wc-ce=v0&wc-register', 'wc-ce=v1']]);
suites = combinations(suites, [['wc-ce=v1&wc-register=true']]);
suites = combinations(suites, [['wc-ce=v1&wc-register=true'], ['forceShadyDom=true', '']]);
console.log('Testing suites:\n\t' + suites.join('\n\t'));

WCT.loadSuites(suites);
Expand Down
18 changes: 9 additions & 9 deletions test/smoke/attributes-polymer.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../polymer.html">

<script>
(function() {

'use strict';

var attributes = new Polymer.AttributeToProperty();

class XBase extends HTMLElement {

createdCallback() {

constructor() {
super();
this.textContent = 'hello world';
attributes.simulateV1AttributeCallbacks(this);
// test attributeChanged
this.setAttribute('attr', 'attr');
console.log('attributeToProperty: pull is', this.pull);
Expand All @@ -44,17 +44,17 @@
}

XBase.observedAttributes = {
pull: true,
pull: true,
attr: true
};

document.registerElement('x-base', XBase);
customElements.define('x-base', XBase);

// *********************

// working up to this...
Polymer({

is: 'x-polymer',

hostAttributes: {
Expand All @@ -64,7 +64,7 @@
properties: {
pull: {type: String}
},

ready: function() {
this.textContent = this.localName;
console.log('attribute set to property: pull is', this.pull);
Expand Down
17 changes: 8 additions & 9 deletions test/smoke/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../src/attributes/attribute-to-property.html">

<script>
(function() {

'use strict';

var attributes = new Polymer.AttributeToProperty();

class XBase extends HTMLElement {

createdCallback() {
this.textContent = 'hello world';
attributes.simulateV1AttributeCallbacks(this);
// test attributeChanged

constructor() {
super();
this.textContent = 'hello world'; // test attributeChanged
this.setAttribute('attr', 'attr');
console.log('attributeToProperty: pull is', this.pull);
}
Expand All @@ -44,11 +43,11 @@
}

XBase.observedAttributes = {
pull: true,
pull: true,
attr: true
};

document.registerElement('x-base', XBase);
customElements.define('x-base', XBase);

})();
</script>
Expand Down
15 changes: 8 additions & 7 deletions test/smoke/bindings.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@

class XBindings extends HTMLElement {

createdCallback() {
constructor() {
super();
var dom = document.importNode(template.content, true);
propertyEffects.setupBindings(this, dom, notes);
this.createShadowRoot().appendChild(dom);
this.attachShadow({mode:'open'}).appendChild(dom);
}

concat(a, b) {
Expand All @@ -78,7 +79,7 @@

propertyEffects.bindTemplate(XBindings, template);

document.registerElement('x-bindings', XBindings);
customElements.define('x-bindings', XBindings);

///////////////

Expand All @@ -87,11 +88,11 @@

class XClient extends HTMLElement {

createdCallback() {
constructor() {
super();
var dom = document.importNode(clientTemplate.content, true);
propertyEffects.setupBindings(this, dom, clientNotes);
this.createShadowRoot().appendChild(dom);
//this.attachShadow({mode: 'open'}).appendChild(dom);
this.attachShadow({mode: 'open'}).appendChild(dom);
}

}
Expand All @@ -100,7 +101,7 @@
propertyEffects.createNotifyingProperty(XClient, 'prop');
propertyEffects.bindTemplate(XClient, clientTemplate);

document.registerElement('x-client', XClient);
customElements.define('x-client', XClient);

})();
</script>
Expand Down
Loading

0 comments on commit 24881c4

Please sign in to comment.