Skip to content

Commit

Permalink
Cleanup modulizer conversion leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Aug 31, 2018
1 parent 0d35437 commit f39b63c
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 72 deletions.
4 changes: 2 additions & 2 deletions lib/elements/dom-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { templatize } from '../utils/templatize.js';
import { Debouncer } from '../utils/debounce.js';
import { enqueueDebouncer, flush } from '../utils/flush.js';
import { microTask } from '../utils/async.js';
import { root as root$0 } from '../utils/path.js';
import { root } from '../utils/path.js';

/**
* The `<dom-if>` element will stamp a light-dom `<template>` child when
Expand Down Expand Up @@ -211,7 +211,7 @@ export class DomIf extends PolymerElement {
// properties so `__syncHostProperties` can sync them the next
// time `if` becomes true
this.__invalidProps = this.__invalidProps || Object.create(null);
this.__invalidProps[root$0(prop)] = true;
this.__invalidProps[root(prop)] = true;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/elements/dom-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
import { PolymerElement } from '../../polymer-element.js';

import { TemplateInstanceBase, templatize, modelForElement as modelForElement$0 } from '../utils/templatize.js'; // eslint-disable-line no-unused-vars
import { TemplateInstanceBase, templatize, modelForElement } from '../utils/templatize.js'; // eslint-disable-line no-unused-vars
import { Debouncer } from '../utils/debounce.js';
import { enqueueDebouncer, flush } from '../utils/flush.js';
import { OptionalMutableData } from '../mixins/mutable-data.js';
Expand Down Expand Up @@ -722,7 +722,7 @@ export class DomRepeat extends domRepeatBase {
* the element.
*/
modelForElement(el) {
return modelForElement$0(this.template, el);
return modelForElement(this.template, el);
}

}
Expand Down
12 changes: 6 additions & 6 deletions lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { DirMixin } from '../mixins/dir-mixin.js';
import { dedupingMixin } from '../utils/mixin.js';
import '../utils/render-status.js';
import '../utils/unresolved.js';
import { dom as dom$0, matchesSelector } from './polymer.dom.js';
import { dom, matchesSelector } from './polymer.dom.js';
import { setTouchAction } from '../utils/gestures.js';
import { Debouncer } from '../utils/debounce.js';
import { timeOut, microTask } from '../utils/async.js';
import { get as get$0 } from '../utils/path.js';
import { get } from '../utils/path.js';

let styleInterface = window.ShadyCSS;

Expand Down Expand Up @@ -516,7 +516,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
*/
getEffectiveChildNodes() {
const thisEl = /** @type {Element} */ (this);
const domApi = /** @type {DomApi} */(dom$0(thisEl));
const domApi = /** @type {DomApi} */(dom(thisEl));
return domApi.getEffectiveChildNodes();
}

Expand All @@ -530,7 +530,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
*/
queryDistributedElements(selector) {
const thisEl = /** @type {Element} */ (this);
const domApi = /** @type {DomApi} */(dom$0(thisEl));
const domApi = /** @type {DomApi} */(dom(thisEl));
return domApi.queryDistributedElements(selector);
}

Expand Down Expand Up @@ -602,7 +602,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
*/
getContentChildNodes(slctr) {
let content = this.root.querySelector(slctr || 'slot');
return content ? /** @type {DomApi} */(dom$0(content)).getDistributedNodes() : [];
return content ? /** @type {DomApi} */(dom(content)).getDistributedNodes() : [];
}

/**
Expand Down Expand Up @@ -906,7 +906,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
return arrayOrPath.splice(index, 1);
}
} else {
let arr = get$0(this, arrayOrPath);
let arr = get(this, arrayOrPath);
index = arr.indexOf(item);
if (index >= 0) {
return this.splice(arrayOrPath, index, 1);
Expand Down
6 changes: 3 additions & 3 deletions lib/legacy/templatizer-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The complete set of contributors may be found at http://polymer.github.io/CONTRI
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import { TemplateInstanceBase, templatize as templatize$0, modelForElement as modelForElement$0 } from '../utils/templatize.js'; // eslint-disable-line no-unused-vars
import { TemplateInstanceBase, templatize, modelForElement } from '../utils/templatize.js'; // eslint-disable-line no-unused-vars

/**
* @typedef {{
Expand Down Expand Up @@ -99,7 +99,7 @@ export const Templatizer = {
*/
templatize(template, mutableData) {
this._templatizerTemplate = template;
this.ctor = templatize$0(template, this, {
this.ctor = templatize(template, this, {
mutableData: Boolean(mutableData),
parentModel: this._parentModel,
instanceProps: this._instanceProps,
Expand Down Expand Up @@ -137,6 +137,6 @@ export const Templatizer = {
* @this {TemplatizerUser}
*/
modelForElement(el) {
return modelForElement$0(this._templatizerTemplate, el);
return modelForElement(this._templatizerTemplate, el);
}
};
20 changes: 10 additions & 10 deletions lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
import '../utils/boot.js';

import { rootPath as rootPath$0 } from '../utils/settings.js';
import { rootPath } from '../utils/settings.js';
import { dedupingMixin } from '../utils/mixin.js';
import { stylesFromTemplate, stylesFromModuleImports } from '../utils/style-gather.js';
import { pathFromUrl, resolveCss, resolveUrl as resolveUrl$0 } from '../utils/resolve-url.js';
import { pathFromUrl, resolveCss, resolveUrl } from '../utils/resolve-url.js';
import { DomModule } from '../elements/dom-module.js';
import { PropertyEffects } from './property-effects.js';
import { PropertiesMixin } from './properties-mixin.js';
Expand Down Expand Up @@ -279,7 +279,7 @@ export const ElementMixin = dedupingMixin(base => {

/**
* Look up template from dom-module for element
*
*
* @param {!string} is Element name to look up
* @return {!HTMLTemplateElement} Template found in dom module, or
* undefined if not found
Expand Down Expand Up @@ -424,14 +424,14 @@ export const ElementMixin = dedupingMixin(base => {
// - constructor._template: memoized version of constructor.template
// - prototype._template: working template for the element, which will be
// parsed and modified in place. It is a cloned version of
// constructor.template, saved in _finalizeClass(). Note that before
// constructor.template, saved in _finalizeClass(). Note that before
// this getter is called, for legacy elements this could be from a
// _template field on the info object passed to Polymer(), a behavior,
// or set in registered(); once the static getter runs, a clone of it
// will overwrite it on the prototype as the working template.
// will overwrite it on the prototype as the working template.
if (!this.hasOwnProperty(JSCompiler_renameProperty('_template', this))) {
this._template =
// If user has put template on prototype (e.g. in legacy via registered
// If user has put template on prototype (e.g. in legacy via registered
// callback or info object), prefer that first
this.prototype.hasOwnProperty(JSCompiler_renameProperty('_template', this.prototype)) ?
this.prototype._template :
Expand Down Expand Up @@ -522,7 +522,7 @@ export const ElementMixin = dedupingMixin(base => {
this.constructor._finalizeTemplate(/** @type {!HTMLElement} */(this).localName);
super._initializeProperties();
// set path defaults
this.rootPath = rootPath$0;
this.rootPath = rootPath;
this.importPath = this.constructor.importPath;
// apply property defaults...
let p$ = propertyDefaults(this.constructor);
Expand Down Expand Up @@ -576,7 +576,7 @@ export const ElementMixin = dedupingMixin(base => {
if (template && !template.__polymerFinalized) {
template.__polymerFinalized = true;
const importPath = this.importPath;
const baseURI = importPath ? resolveUrl$0(importPath) : '';
const baseURI = importPath ? resolveUrl(importPath) : '';
// e.g. support `include="module-name"`, and ShadyCSS
processElementStyles(this, template, is, baseURI);
this.prototype._bindTemplate(template);
Expand Down Expand Up @@ -710,9 +710,9 @@ export const ElementMixin = dedupingMixin(base => {
*/
resolveUrl(url, base) {
if (!base && this.importPath) {
base = resolveUrl$0(this.importPath);
base = resolveUrl(this.importPath);
}
return resolveUrl$0(url, base);
return resolveUrl(url, base);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/mixins/gesture-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
import '../utils/boot.js';

import { dedupingMixin } from '../utils/mixin.js';
import * as gestures$0 from '../utils/gestures.js';

const gestures = gestures$0;
import { gestures } from '../utils/gestures.js';

/**
* Element class mixin that provides API for adding Polymer's cross-platform
Expand Down
8 changes: 3 additions & 5 deletions lib/mixins/property-accessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
import '../utils/boot.js';

import { dedupingMixin } from '../utils/mixin.js';
import * as caseMap$0 from '../utils/case-map.js';
import { camelToDashCase, dashToCamelCase } from '../utils/case-map.js';
import { PropertiesChanged } from './properties-changed.js';

let caseMap = caseMap$0;

// Save map of native properties; this forms a blacklist or properties
// that won't have their values "saved" by `saveAccessorValue`, since
// reading from an HTMLElement accessor from the context of a prototype throws
Expand Down Expand Up @@ -124,7 +122,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
static createPropertiesForAttributes() {
let a$ = this.observedAttributes;
for (let i=0; i < a$.length; i++) {
this.prototype._createPropertyAccessor(caseMap.dashToCamelCase(a$[i]));
this.prototype._createPropertyAccessor(dashToCamelCase(a$[i]));
}
}

Expand All @@ -137,7 +135,7 @@ export const PropertyAccessors = dedupingMixin(superClass => {
* @protected
*/
static attributeNameForProperty(property) {
return caseMap.camelToDashCase(property);
return camelToDashCase(property);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/smoke/data-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ <h3>Table {{index}}:</h3>
</div>
</template>
<script type="module">
import { Polymer, version as version$0 } from '../../lib/utils/boot.js';
import { Polymer, version } from '../../lib/utils/boot.js';
var params = document.location.search.substring(1).split('&').map(p=>p.split('='))
.reduce((m, p)=>{return m[p[0]] = p[1], m;}, {});
Polymer({
Expand Down Expand Up @@ -295,7 +295,7 @@ <h3>Table {{index}}:</h3>
return value.toFixed(decimals);
},
ready: function() {
this.version = version$0 || 'alacarte';
this.version = version || 'alacarte';
if (!this.setProperties) {
this.setProperties = function(props) {
for (var p in props) {
Expand Down
6 changes: 3 additions & 3 deletions test/smoke/html-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<body>
<script type="module">
import { PolymerElement } from '../../polymer-element.js';
import { html as html$0 } from '../../lib/utils/html-tag.js';
const html = html$0;
import { html } from '../../lib/utils/html-tag.js';

class SuperClass extends PolymerElement {
static get is() {return 'super-class';}
static get template() {
Expand Down Expand Up @@ -64,4 +64,4 @@ <h3 id="name">${this.is}</h3>
<super-class></super-class>
<sub-class></sub-class>
<x-string></x-string>
</body>
</body>
20 changes: 7 additions & 13 deletions test/unit/case-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@
<body>

<script type="module">
import * as caseMap$0 from '../../lib/utils/case-map.js';
import { camelToDashCase, dashToCamelCase } from '../../lib/utils/case-map.js';
suite('case-map', function() {
var caseMap;

setup(function() {
caseMap = caseMap$0;
});

test('camelToDashCase converts to dashes', function() {
assert.equal(caseMap.camelToDashCase('camelCase'), 'camel-case');
assert.equal(caseMap.camelToDashCase('camelCCase'), 'camel-c-case');
assert.equal(camelToDashCase('camelCase'), 'camel-case');
assert.equal(camelToDashCase('camelCCase'), 'camel-c-case');
});

test('dashToCamelCase converts to camelCase', function() {
assert.equal(caseMap.dashToCamelCase('camel-case'), 'camelCase');
assert.equal(caseMap.dashToCamelCase('camel-c-case'), 'camelCCase');
assert.equal(dashToCamelCase('camel-case'), 'camelCase');
assert.equal(dashToCamelCase('camel-c-case'), 'camelCCase');
});

test('camelToDashCase and dashToCamelCase reverse the other function', function() {
var camelCase = caseMap.dashToCamelCase('camel-c-case');
assert.equal(caseMap.camelToDashCase(camelCase), 'camel-c-case');
var camelCase = dashToCamelCase('camel-c-case');
assert.equal(camelToDashCase(camelCase), 'camel-c-case');
});
});
</script>
10 changes: 5 additions & 5 deletions test/unit/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import './gestures-elements.js';
import { afterNextRender } from '../../lib/utils/render-status.js';
import * as gestures from '../../lib/utils/gestures.js';
import { resetMouseCanceller, deepTargetFind, recognizers as recognizers$0, addListener, removeListener } from '../../lib/utils/gestures.js';
import { resetMouseCanceller, deepTargetFind, recognizers, addListener, removeListener } from '../../lib/utils/gestures.js';

suite('simulate events', function() {

Expand Down Expand Up @@ -474,22 +474,22 @@
el.dispatchEvent(ev);

// some recognizers do not track the document, like tap
var recognizers = recognizers$0.filter(function(r) {
var recs = recognizers.filter(function(r) {
return r.info.hasOwnProperty('movefn') &&
r.info.hasOwnProperty('upfn');
});

assert.isAbove(recognizers.length, 0, 'some recognizers track the document');
assert.isAbove(recs.length, 0, 'some recognizers track the document');

recognizers.forEach(function(r) {
recs.forEach(function(r) {
assert.isFunction(r.info.movefn, r.name + ' movefn');
assert.isFunction(r.info.upfn, r.name + ' upfn');
});

ev = new CustomEvent('mouseup', {bubbles: true, composed: true});
el.dispatchEvent(ev);

recognizers.forEach(function(r) {
recs.forEach(function(r) {
assert.isNull(r.info.movefn, r.name + ' movefn');
assert.isNull(r.info.upfn, r.name + ' upfn');
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/importHref.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<x-test></x-test>

<script type="module">
import { importHref as importHref$0 } from '../../lib/utils/import-href.js';
import { importHref } from '../../lib/utils/import-href.js';
import { PolymerElement } from '../../polymer-element.js';
import { Base } from '../../polymer-legacy.js';

Expand All @@ -30,7 +30,7 @@

test('importing polymer via Polymer.importHref', function(done) {
assert.notOk(PolymerElement);
importHref$0('../../polymer.html', function() {
importHref('../../polymer.html', function() {
assert.ok(PolymerElement);
done();
});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/render-status.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
<body>

<script type="module">
import { beforeNextRender as beforeNextRender$0, afterNextRender as afterNextRender$0 } from '../../lib/utils/render-status.js';
import { beforeNextRender, afterNextRender } from '../../lib/utils/render-status.js';
import { LegacyElementMixin } from '../../lib/legacy/legacy-element-mixin.js';
class XFoo extends LegacyElementMixin(HTMLElement) {
ready() {
super.ready();
sinon.spy(this, 'beforeNextRender');
sinon.spy(this, 'stillBeforeNextRender');
beforeNextRender$0(this, this.beforeNextRender,
beforeNextRender(this, this.beforeNextRender,
['before']);
}

beforeNextRender() {
beforeNextRender$0(this, this.stillBeforeNextRender,
beforeNextRender(this, this.stillBeforeNextRender,
['still-before']);
}
stillBeforeNextRender() {
Expand All @@ -46,13 +46,13 @@
super.ready();
sinon.spy(this, 'afterNextRender');
sinon.spy(this, 'afterAfterNextRender');
afterNextRender$0(this, (a) => {
afterNextRender(this, (a) => {
this.afterNextRender(a);
}, ['after']);
}

afterNextRender() {
afterNextRender$0(this, (a) => {
afterNextRender(this, (a) => {
this.afterAfterNextRender(a);
}, ['after-after']);
}
Expand Down
Loading

0 comments on commit f39b63c

Please sign in to comment.