diff --git a/.travis.yml b/.travis.yml
index c56b9b6..872d303 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,19 +3,17 @@ sudo: required
dist: trusty
node_js: stable
addons:
- sauce_connect: true
- firefox: 48.0
+ firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
-before_script:
-- export PATH=$PWD/node_modules/.bin:$PATH
script:
-- npm run build
+- npm install -g bower
+- bower install
- xvfb-run wct
-- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi
+- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'windows 10/microsoftedge@14' -s 'windows 8.1/internet explorer@11' -s 'os x 10.11/safari@10' -s 'os x 10.11/safari@9'; fi
env:
global:
- secure: Fpp9LwJSGOdTrSIImQTlbzxozBsqe/2AJN5OfTXSe12FZxqzz50gevdxQcIlLypKaNyCtjb980DJbwdJR2cXUqaunLZAPWxrKa7ZPwamUxW+zVL7EHqy5zuvD+yJ+Vmk3ahs3WBTVyJ8T3XoaSfo9VumDIcKggWGJwgvM3blIMg=
diff --git a/README.md b/README.md
index d92ed6f..3a9255b 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,6 @@ A suite of polyfills supporting the [Web Components](http://webcomponents.org) s
**Shadow DOM**: provides encapsulation by hiding DOM subtrees under shadow roots ([spec](https://w3c.github.io/webcomponents/spec/shadow/)).
-This also folds in polyfills for `MutationObserver` and `WeakMap`.
-
-
## Releases
Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are two variants:
@@ -75,9 +72,9 @@ Copyright (c) 2015 The Polymer Authors. All rights reserved.
### `WebComponentsReady`
-Under native HTML Imports, `');
-});
-
-// exports
-window.HTMLImports.flags = flags;
-
-})();
diff --git a/src/HTMLImports/Loader.js b/src/HTMLImports/Loader.js
deleted file mode 100644
index 959bcaa..0000000
--- a/src/HTMLImports/Loader.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-window.HTMLImports.addModule(function(scope) {
-
-// imports
-var xhr = scope.xhr;
-var flags = scope.flags;
-
-// This loader supports a dynamic list of urls
-// and an oncomplete callback that is called when the loader is done.
-// NOTE: The polyfill currently does *not* need this dynamism or the
-// onComplete concept. Because of this, the loader could be simplified
-// quite a bit.
-var Loader = function(onLoad, onComplete) {
- this.cache = {};
- this.onload = onLoad;
- this.oncomplete = onComplete;
- this.inflight = 0;
- this.pending = {};
-};
-
-Loader.prototype = {
-
- addNodes: function(nodes) {
- // number of transactions to complete
- this.inflight += nodes.length;
- // commence transactions
- for (var i=0, l=nodes.length, n; (i -1) {
- body = atob(body);
- } else {
- body = decodeURIComponent(body);
- }
- setTimeout(function() {
- this.receive(url, elt, null, body);
- }.bind(this), 0);
- } else {
- var receiveXhr = function(err, resource, redirectedUrl) {
- this.receive(url, elt, err, resource, redirectedUrl);
- }.bind(this);
- xhr.load(url, receiveXhr);
- }
- },
-
- receive: function(url, elt, err, resource, redirectedUrl) {
- this.cache[url] = resource;
- var $p = this.pending[url];
- for (var i=0, l=$p.length, p; (i when we ensure the document is in a ready state
-function whenDocumentReady(callback, doc) {
- if (!isDocumentReady(doc)) {
- var checkReady = function() {
- if (doc.readyState === 'complete' ||
- doc.readyState === requiredReadyState) {
- doc.removeEventListener(READY_EVENT, checkReady);
- whenDocumentReady(callback, doc);
- }
- };
- doc.addEventListener(READY_EVENT, checkReady);
- } else if (callback) {
- callback();
- }
-}
-
-function markTargetLoaded(event) {
- event.target.__loaded = true;
-}
-
-// call when we ensure all imports have loaded
-function watchImportsLoad(callback, doc) {
- var imports = doc.querySelectorAll('link[rel=import]');
- var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = [];
- function checkDone() {
- if (parsedCount == importCount && callback) {
- callback({
- allImports: imports,
- loadedImports: newImports,
- errorImports: errorImports
- });
- }
- }
- function loadedImport(e) {
- markTargetLoaded(e);
- newImports.push(this);
- parsedCount++;
- checkDone();
- }
- function errorLoadingImport(e) {
- errorImports.push(this);
- parsedCount++;
- checkDone();
- }
- if (importCount) {
- for (var i=0, imp; i.content
- // see https://code.google.com/p/chromium/issues/detail?id=249381.
- elt.__resource = resource;
- elt.__error = err;
- if (isImportLink(elt)) {
- var doc = this.documents[url];
- // if we've never seen a document at this url
- if (doc === undefined) {
- // generate an HTMLDocument from data
- doc = err ? null : makeDocument(resource, redirectedUrl || url);
- if (doc) {
- doc.__importLink = elt;
- // note, we cannot use MO to detect parsed nodes because
- // SD polyfill does not report these as mutations.
- this.bootDocument(doc);
- }
- // cache document
- this.documents[url] = doc;
- }
- // don't store import record until we're actually loaded
- // store document resource
- elt.__doc = doc;
- }
- parser.parseNext();
- },
-
- bootDocument: function(doc) {
- this.loadSubtree(doc);
- // observe documents for new elements being added
- this.observer.observe(doc);
- parser.parseNext();
- },
-
- loadedAll: function() {
- parser.parseNext();
- }
-
-};
-
-// loader singleton to handle loading imports
-var importLoader = new Loader(importer.loaded.bind(importer),
- importer.loadedAll.bind(importer));
-
-// observer singleton to handle observing elements in imports
-// NOTE: the observer has a node added callback and this is set
-// by the dynamic importer module.
-importer.observer = new Observer();
-
-function isImportLink(elt) {
- return isLinkRel(elt, IMPORT_LINK_TYPE);
-}
-
-function isLinkRel(elt, rel) {
- return elt.localName === 'link' && elt.getAttribute('rel') === rel;
-}
-
-function hasBaseURIAccessor(doc) {
- return !! Object.getOwnPropertyDescriptor(doc, 'baseURI');
-}
-
-function makeDocument(resource, url) {
- // create a new HTML document
- var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
- // cache the new document's source url
- doc._URL = url;
- // establish a relative path via
- var base = doc.createElement('base');
- base.setAttribute('href', url);
- // add baseURI support to browsers (IE) that lack it.
- if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
- // Use defineProperty since Safari throws an exception when using assignment.
- Object.defineProperty(doc, 'baseURI', {value:url});
- }
- // ensure UTF-8 charset
- var meta = doc.createElement('meta');
- meta.setAttribute('charset', 'utf-8');
-
- doc.head.appendChild(meta);
- doc.head.appendChild(base);
- // install html
- doc.body.innerHTML = resource;
- // TODO(sorvell): ideally this code is not aware of Template polyfill,
- // but for now the polyfill needs help to bootstrap these templates
- if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
- HTMLTemplateElement.bootstrap(doc);
- }
- return doc;
-}
-
-// Polyfill document.baseURI for browsers without it.
-if (!document.baseURI) {
- var baseURIDescriptor = {
- get: function() {
- var base = document.querySelector('base');
- return base ? base.href : window.location.href;
- },
- configurable: true
- };
-
- Object.defineProperty(document, 'baseURI', baseURIDescriptor);
- Object.defineProperty(rootDocument, 'baseURI', baseURIDescriptor);
-}
-
-// exports
-scope.importer = importer;
-scope.importLoader = importLoader;
-
-});
diff --git a/src/HTMLImports/module.js b/src/HTMLImports/module.js
deleted file mode 100644
index 9a9304d..0000000
--- a/src/HTMLImports/module.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-(function(scope) {
-
-// world's simplest module initializer
-var modules = [];
-var addModule = function(module) {
- modules.push(module);
-};
-
-var initializeModules = function() {
- modules.forEach(function(module) {
- module(scope);
- });
-};
-
-// exports
-scope.addModule = addModule;
-scope.initializeModules = initializeModules;
-
-})(window.HTMLImports);
-
diff --git a/src/HTMLImports/parser.js b/src/HTMLImports/parser.js
deleted file mode 100644
index a52d9de..0000000
--- a/src/HTMLImports/parser.js
+++ /dev/null
@@ -1,339 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-window.HTMLImports.addModule(function(scope) {
-
-// imports
-var path = scope.path;
-var rootDocument = scope.rootDocument;
-var flags = scope.flags;
-var isIE = scope.isIE;
-var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
-var IMPORT_SELECTOR = 'link[rel=' + IMPORT_LINK_TYPE + ']';
-
-// importParser
-// highlander object to manage parsing of imports
-// parses import related elements and ensures proper parse order
-// parse order is enforced by crawling the tree and monitoring which elements
-// have been parsed;
-// elements can be dynamically added to imports. These are maintained in a
-// separate queue and parsed after all other elements.
-var importParser = {
-
- // parse selectors for main document elements
- documentSelectors: IMPORT_SELECTOR,
-
- // parse selectors for import document elements
- importsSelectors: [
- IMPORT_SELECTOR,
- 'link[rel=stylesheet]:not([type])',
- 'style:not([type])',
- 'script:not([type])',
- 'script[type="application/javascript"]',
- 'script[type="text/javascript"]'
- ].join(','),
-
- map: {
- link: 'parseLink',
- script: 'parseScript',
- style: 'parseStyle'
- },
-
- dynamicElements: [],
-
- // try to parse the next import in the tree
- parseNext: function() {
- var next = this.nextToParse();
- if (next) {
- this.parse(next);
- }
- },
-
- parse: function(elt) {
- if (this.isParsed(elt)) {
- flags.parse && console.log('[%s] is already parsed', elt.localName);
- return;
- }
- var fn = this[this.map[elt.localName]];
- if (fn) {
- this.markParsing(elt);
- fn.call(this, elt);
- }
- },
-
- // marks an element for dynamic parsing and attempts to parse the next element
- parseDynamic: function(elt, quiet) {
- this.dynamicElements.push(elt);
- if (!quiet) {
- this.parseNext();
- }
- },
-
- // only 1 element may be parsed at a time; parsing is async so each
- // parsing implementation must inform the system that parsing is complete
- // via markParsingComplete.
- // To prompt the system to parse the next element, parseNext should then be
- // called.
- // Note, parseNext used to be included at the end of markParsingComplete, but
- // we must not do this so that, for example, we can (1) mark parsing complete
- // then (2) fire an import load event, and then (3) parse the next resource.
- markParsing: function(elt) {
- flags.parse && console.log('parsing', elt);
- this.parsingElement = elt;
- },
-
- markParsingComplete: function(elt) {
- elt.__importParsed = true;
- this.markDynamicParsingComplete(elt);
- if (elt.__importElement) {
- elt.__importElement.__importParsed = true;
- this.markDynamicParsingComplete(elt.__importElement);
- }
- this.parsingElement = null;
- flags.parse && console.log('completed', elt);
- },
-
- markDynamicParsingComplete: function(elt) {
- var i = this.dynamicElements.indexOf(elt);
- if (i >= 0) {
- this.dynamicElements.splice(i, 1);
- }
- },
-
- parseImport: function(elt) {
- elt.import = elt.__doc;
- if (window.HTMLImports.__importsParsingHook) {
- window.HTMLImports.__importsParsingHook(elt);
- }
- if (elt.import) {
- elt.import.__importParsed = true;
- }
- this.markParsingComplete(elt);
- // fire load event
- if (elt.__resource && !elt.__error) {
- elt.dispatchEvent(new CustomEvent('load', {bubbles: false}));
- } else {
- elt.dispatchEvent(new CustomEvent('error', {bubbles: false}));
- }
- // TODO(sorvell): workaround for Safari addEventListener not working
- // for elements not in the main document.
- if (elt.__pending) {
- var fn;
- while (elt.__pending.length) {
- fn = elt.__pending.shift();
- if (fn) {
- fn({target: elt});
- }
- }
- }
- this.parseNext();
- },
-
- parseLink: function(linkElt) {
- if (nodeIsImport(linkElt)) {
- this.parseImport(linkElt);
- } else {
- // make href absolute
- linkElt.href = linkElt.href;
- this.parseGeneric(linkElt);
- }
- },
-
- parseStyle: function(elt) {
- // TODO(sorvell): style element load event can just not fire so clone styles
- var src = elt;
- elt = cloneStyle(elt);
- src.__appliedElement = elt;
- elt.__importElement = src;
- this.parseGeneric(elt);
- },
-
- parseGeneric: function(elt) {
- this.trackElement(elt);
- this.addElementToDocument(elt);
- },
-
- rootImportForElement: function(elt) {
- var n = elt;
- while (n.ownerDocument.__importLink) {
- n = n.ownerDocument.__importLink;
- }
- return n;
- },
-
- addElementToDocument: function(elt) {
- var port = this.rootImportForElement(elt.__importElement || elt);
- port.parentNode.insertBefore(elt, port);
- },
-
- // tracks when a loadable element has loaded
- trackElement: function(elt, callback) {
- var self = this;
- var done = function(e) {
- // make sure we don't get multiple load/error signals (FF seems to do
- // this sometimes when
-
-
- could become:
-
-
-
-
-
-
- Note the use of @polyfill in the comment above a ShadowDOM specific style
- declaration. This is a directive to the styling shim to use the selector
- in comments in lieu of the next selector when running under polyfill.
-*/
-(function(scope) {
-
-var ShadowCSS = {
- strictStyling: false,
- registry: {},
- // Shim styles for a given root associated with a name and extendsName
- // 1. cache root styles by name
- // 2. optionally tag root nodes with scope name
- // 3. shim polyfill directives /* @polyfill */ and /* @polyfill-rule */
- // 4. shim :host and scoping
- shimStyling: function(root, name, extendsName) {
- var scopeStyles = this.prepareRoot(root, name, extendsName);
- var typeExtension = this.isTypeExtension(extendsName);
- var scopeSelector = this.makeScopeSelector(name, typeExtension);
- // use caching to make working with styles nodes easier and to facilitate
- // lookup of extendee
- var cssText = stylesToCssText(scopeStyles, true);
- cssText = this.scopeCssText(cssText, scopeSelector);
- // cache shimmed css on root for user extensibility
- if (root) {
- root.shimmedStyle = cssText;
- }
- // add style to document
- this.addCssToDocument(cssText, name);
- },
- /*
- * Shim a style element with the given selector. Returns cssText that can
- * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
- */
- shimStyle: function(style, selector) {
- return this.shimCssText(style.textContent, selector);
- },
- /*
- * Shim some cssText with the given selector. Returns cssText that can
- * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
- */
- shimCssText: function(cssText, selector) {
- cssText = this.insertDirectives(cssText);
- return this.scopeCssText(cssText, selector);
- },
- makeScopeSelector: function(name, typeExtension) {
- if (name) {
- return typeExtension ? '[is=' + name + ']' : name;
- }
- return '';
- },
- isTypeExtension: function(extendsName) {
- return extendsName && extendsName.indexOf('-') < 0;
- },
- prepareRoot: function(root, name, extendsName) {
- var def = this.registerRoot(root, name, extendsName);
- this.replaceTextInStyles(def.rootStyles, this.insertDirectives);
- // remove existing style elements
- this.removeStyles(root, def.rootStyles);
- // apply strict attr
- if (this.strictStyling) {
- this.applyScopeToContent(root, name);
- }
- return def.scopeStyles;
- },
- removeStyles: function(root, styles) {
- for (var i=0, l=styles.length, s; (i .bar { }
- *
- * to
- *
- * scopeName.foo > .bar
- */
- convertColonHost: function(cssText) {
- return this.convertColonRule(cssText, cssColonHostRe,
- this.colonHostPartReplacer);
- },
- /*
- * convert a rule like :host-context(.foo) > .bar { }
- *
- * to
- *
- * scopeName.foo > .bar, .foo scopeName > .bar { }
- *
- * and
- *
- * :host-context(.foo:host) .bar { ... }
- *
- * to
- *
- * scopeName.foo .bar { ... }
- */
- convertColonHostContext: function(cssText) {
- return this.convertColonRule(cssText, cssColonHostContextRe,
- this.colonHostContextPartReplacer);
- },
- convertColonRule: function(cssText, regExp, partReplacer) {
- // p1 = :host, p2 = contents of (), p3 rest of rule
- return cssText.replace(regExp, function(m, p1, p2, p3) {
- p1 = polyfillHostNoCombinator;
- if (p2) {
- var parts = p2.split(','), r = [];
- for (var i=0, l=parts.length, p; (i .zot becomes .foo[name].bar[name] > .zot[name]
- applyStrictSelectorScope: function(selector, scopeSelector) {
- scopeSelector = scopeSelector.replace(/\[is=([^\]]*)\]/g, '$1');
- var splits = [' ', '>', '+', '~'],
- scoped = selector,
- attrName = '[' + scopeSelector + ']';
- splits.forEach(function(sep) {
- var parts = scoped.split(sep);
- scoped = parts.map(function(p) {
- // remove :host since it should be unnecessary
- var t = p.trim().replace(polyfillHostRe, '');
- if (t && (splits.indexOf(t) < 0) && (t.indexOf(attrName) < 0)) {
- p = t.replace(/([^:]*)(:*)(.*)/, '$1' + attrName + '$2$3');
- }
- return p;
- }).join(sep);
- });
- return scoped;
- },
- insertPolyfillHostInCssText: function(selector) {
- return selector.replace(colonHostContextRe, polyfillHostContext).replace(
- colonHostRe, polyfillHost);
- },
- propertiesFromRule: function(rule) {
- var cssText = rule.style.cssText;
- // TODO(sorvell): Safari cssom incorrectly removes quotes from the content
- // property. (https://bugs.webkit.org/show_bug.cgi?id=118045)
- // don't replace attr rules
- if (rule.style.content && !rule.style.content.match(/['"]+|attr/)) {
- cssText = cssText.replace(/content:[^;]*;/g, 'content: \'' +
- rule.style.content + '\';');
- }
- // TODO(sorvell): we can workaround this issue here, but we need a list
- // of troublesome properties to fix https://github.com/Polymer/platform/issues/53
- //
- // inherit rules can be omitted from cssText
- // TODO(sorvell): remove when Blink bug is fixed:
- // https://code.google.com/p/chromium/issues/detail?id=358273
- var style = rule.style;
- for (var i in style) {
- if (style[i] === 'initial') {
- cssText += i + ': initial; ';
- }
- }
- return cssText;
- },
- replaceTextInStyles: function(styles, action) {
- if (styles && action) {
- if (!(styles instanceof Array)) {
- styles = [styles];
- }
- Array.prototype.forEach.call(styles, function(s) {
- s.textContent = action.call(this, s.textContent);
- }, this);
- }
- },
- addCssToDocument: function(cssText, name) {
- if (cssText.match('@import')) {
- addOwnSheet(cssText, name);
- } else {
- addCssToDocument(cssText);
- }
- }
-};
-
-var selectorRe = /([^{]*)({[\s\S]*?})/gim,
- cssCommentRe = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,
- // TODO(sorvell): remove either content or comment
- cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,
- cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,
- // TODO(sorvell): remove either content or comment
- cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,
- cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,
- // TODO(sorvell): remove either content or comment
- cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,
- cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,
- cssPseudoRe = /::(x-[^\s{,(]*)/gim,
- cssPartRe = /::part\(([^)]*)\)/gim,
- // note: :host pre-processed to -shadowcsshost.
- polyfillHost = '-shadowcsshost',
- // note: :host-context pre-processed to -shadowcsshostcontext.
- polyfillHostContext = '-shadowcsscontext',
- parenSuffix = ')(?:\\((' +
- '(?:\\([^)(]*\\)|[^)(]*)+?' +
- ')\\))?([^,{]*)';
- var cssColonHostRe = new RegExp('(' + polyfillHost + parenSuffix, 'gim'),
- cssColonHostContextRe = new RegExp('(' + polyfillHostContext + parenSuffix, 'gim'),
- selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$',
- colonHostRe = /\:host/gim,
- colonHostContextRe = /\:host-context/gim,
- /* host name without combinator */
- polyfillHostNoCombinator = polyfillHost + '-no-combinator',
- polyfillHostRe = new RegExp(polyfillHost, 'gim'),
- polyfillHostContextRe = new RegExp(polyfillHostContext, 'gim'),
- shadowDOMSelectorsRe = [
- />>>/g,
- /::shadow/g,
- /::content/g,
- // Deprecated selectors
- /\/deep\//g, // former >>>
- /\/shadow\//g, // former ::shadow
- /\/shadow-deep\//g, // former /deep/
- /\^\^/g, // former /shadow/
- /\^(?!=)/g // former /shadow-deep/
- ];
-
-function stylesToCssText(styles, preserveComments) {
- var cssText = '';
- Array.prototype.forEach.call(styles, function(s) {
- cssText += s.textContent + '\n\n';
- });
- // strip comments for easier processing
- if (!preserveComments) {
- cssText = cssText.replace(cssCommentRe, '');
- }
- return cssText;
-}
-
-function cssTextToStyle(cssText) {
- var style = document.createElement('style');
- style.textContent = cssText;
- return style;
-}
-
-function cssToRules(cssText) {
- var style = cssTextToStyle(cssText);
- document.head.appendChild(style);
- var rules = [];
- if (style.sheet) {
- // TODO(sorvell): Firefox throws when accessing the rules of a stylesheet
- // with an @import
- // https://bugzilla.mozilla.org/show_bug.cgi?id=625013
- try {
- rules = style.sheet.cssRules;
- } catch(e) {
- //
- }
- } else {
- console.warn('sheet not found', style);
- }
- style.parentNode.removeChild(style);
- return rules;
-}
-
-var frame = document.createElement('iframe');
-frame.style.display = 'none';
-
-function initFrame() {
- frame.initialized = true;
- document.body.appendChild(frame);
- var doc = frame.contentDocument;
- var base = doc.createElement('base');
- base.href = document.baseURI;
- doc.head.appendChild(base);
-}
-
-function inFrame(fn) {
- if (!frame.initialized) {
- initFrame();
- }
- document.body.appendChild(frame);
- fn(frame.contentDocument);
- document.body.removeChild(frame);
-}
-
-// TODO(sorvell): use an iframe if the cssText contains an @import to workaround
-// https://code.google.com/p/chromium/issues/detail?id=345114
-var isChrome = navigator.userAgent.match('Chrome');
-function withCssRules(cssText, callback) {
- if (!callback) {
- return;
- }
- var rules;
- if (cssText.match('@import') && isChrome) {
- var style = cssTextToStyle(cssText);
- inFrame(function(doc) {
- doc.head.appendChild(style.impl);
- rules = Array.prototype.slice.call(style.sheet.cssRules, 0);
- callback(rules);
- });
- } else {
- rules = cssToRules(cssText);
- callback(rules);
- }
-}
-
-function rulesToCss(cssRules) {
- for (var i=0, css=[]; i < cssRules.length; i++) {
- css.push(cssRules[i].cssText);
- }
- return css.join('\n\n');
-}
-
-function addCssToDocument(cssText) {
- if (cssText) {
- getSheet().appendChild(document.createTextNode(cssText));
- }
-}
-
-function addOwnSheet(cssText, name) {
- var style = cssTextToStyle(cssText);
- style.setAttribute(name, '');
- style.setAttribute(SHIMMED_ATTRIBUTE, '');
- document.head.appendChild(style);
-}
-
-var SHIM_ATTRIBUTE = 'shim-shadowdom';
-var SHIMMED_ATTRIBUTE = 'shim-shadowdom-css';
-var NO_SHIM_ATTRIBUTE = 'no-shim';
-
-var sheet;
-function getSheet() {
- if (!sheet) {
- sheet = document.createElement("style");
- sheet.setAttribute(SHIMMED_ATTRIBUTE, '');
- sheet[SHIMMED_ATTRIBUTE] = true;
- }
- return sheet;
-}
-
-// add polyfill stylesheet to document
-if (window.ShadowDOMPolyfill) {
- addCssToDocument('style { display: none !important; }\n');
- var doc = ShadowDOMPolyfill.wrap(document);
- var head = doc.querySelector('head');
- head.insertBefore(getSheet(), head.childNodes[0]);
-
- // TODO(sorvell): monkey-patching HTMLImports is abusive;
- // consider a better solution.
- document.addEventListener('DOMContentLoaded', function() {
- var urlResolver = scope.urlResolver;
-
- if (window.HTMLImports && !HTMLImports.useNative) {
- var SHIM_SHEET_SELECTOR = 'link[rel=stylesheet]' +
- '[' + SHIM_ATTRIBUTE + ']';
- var SHIM_STYLE_SELECTOR = 'style[' + SHIM_ATTRIBUTE + ']';
- HTMLImports.importer.documentPreloadSelectors += ',' + SHIM_SHEET_SELECTOR;
- HTMLImports.importer.importsPreloadSelectors += ',' + SHIM_SHEET_SELECTOR;
-
- HTMLImports.parser.documentSelectors = [
- HTMLImports.parser.documentSelectors,
- SHIM_SHEET_SELECTOR,
- SHIM_STYLE_SELECTOR
- ].join(',');
-
- var originalParseGeneric = HTMLImports.parser.parseGeneric;
-
- HTMLImports.parser.parseGeneric = function(elt) {
- if (elt[SHIMMED_ATTRIBUTE]) {
- return;
- }
- var style = elt.__importElement || elt;
- if (!style.hasAttribute(SHIM_ATTRIBUTE)) {
- originalParseGeneric.call(this, elt);
- return;
- }
- if (elt.__resource) {
- style = elt.ownerDocument.createElement('style');
- style.textContent = elt.__resource;
- }
- // relay on HTMLImports for path fixup
- HTMLImports.path.resolveUrlsInStyle(style, elt.href);
- style.textContent = ShadowCSS.shimStyle(style);
- style.removeAttribute(SHIM_ATTRIBUTE, '');
- style.setAttribute(SHIMMED_ATTRIBUTE, '');
- style[SHIMMED_ATTRIBUTE] = true;
- // place in document
- if (style.parentNode !== head) {
- // replace links in head
- if (elt.parentNode === head) {
- head.replaceChild(style, elt);
- } else {
- this.addElementToDocument(style);
- }
- }
- style.__importParsed = true;
- this.markParsingComplete(elt);
- this.parseNext();
- }
-
- var hasResource = HTMLImports.parser.hasResource;
- HTMLImports.parser.hasResource = function(node) {
- if (node.localName === 'link' && node.rel === 'stylesheet' &&
- node.hasAttribute(SHIM_ATTRIBUTE)) {
- return (node.__resource);
- } else {
- return hasResource.call(this, node);
- }
- }
-
- }
- });
-}
-
-// exports
-scope.ShadowCSS = ShadowCSS;
-
-})(window.WebComponents);
diff --git a/src/ShadowDOM/ArraySplice.js b/src/ShadowDOM/ArraySplice.js
deleted file mode 100644
index f87800a..0000000
--- a/src/ShadowDOM/ArraySplice.js
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- function newSplice(index, removed, addedCount) {
- return {
- index: index,
- removed: removed,
- addedCount: addedCount
- };
- }
-
- var EDIT_LEAVE = 0;
- var EDIT_UPDATE = 1;
- var EDIT_ADD = 2;
- var EDIT_DELETE = 3;
-
- function ArraySplice() {}
-
- ArraySplice.prototype = {
-
- // Note: This function is *based* on the computation of the Levenshtein
- // "edit" distance. The one change is that "updates" are treated as two
- // edits - not one. With Array splices, an update is really a delete
- // followed by an add. By retaining this, we optimize for "keeping" the
- // maximum array items in the original array. For example:
- //
- // 'xxxx123' -> '123yyyy'
- //
- // With 1-edit updates, the shortest path would be just to update all seven
- // characters. With 2-edit updates, we delete 4, leave 3, and add 4. This
- // leaves the substring '123' intact.
- calcEditDistances: function(current, currentStart, currentEnd,
- old, oldStart, oldEnd) {
- // "Deletion" columns
- var rowCount = oldEnd - oldStart + 1;
- var columnCount = currentEnd - currentStart + 1;
- var distances = new Array(rowCount);
-
- // "Addition" rows. Initialize null column.
- for (var i = 0; i < rowCount; i++) {
- distances[i] = new Array(columnCount);
- distances[i][0] = i;
- }
-
- // Initialize null row
- for (var j = 0; j < columnCount; j++)
- distances[0][j] = j;
-
- for (var i = 1; i < rowCount; i++) {
- for (var j = 1; j < columnCount; j++) {
- if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
- distances[i][j] = distances[i - 1][j - 1];
- else {
- var north = distances[i - 1][j] + 1;
- var west = distances[i][j - 1] + 1;
- distances[i][j] = north < west ? north : west;
- }
- }
- }
-
- return distances;
- },
-
- // This starts at the final weight, and walks "backward" by finding
- // the minimum previous weight recursively until the origin of the weight
- // matrix.
- spliceOperationsFromEditDistances: function(distances) {
- var i = distances.length - 1;
- var j = distances[0].length - 1;
- var current = distances[i][j];
- var edits = [];
- while (i > 0 || j > 0) {
- if (i == 0) {
- edits.push(EDIT_ADD);
- j--;
- continue;
- }
- if (j == 0) {
- edits.push(EDIT_DELETE);
- i--;
- continue;
- }
- var northWest = distances[i - 1][j - 1];
- var west = distances[i - 1][j];
- var north = distances[i][j - 1];
-
- var min;
- if (west < north)
- min = west < northWest ? west : northWest;
- else
- min = north < northWest ? north : northWest;
-
- if (min == northWest) {
- if (northWest == current) {
- edits.push(EDIT_LEAVE);
- } else {
- edits.push(EDIT_UPDATE);
- current = northWest;
- }
- i--;
- j--;
- } else if (min == west) {
- edits.push(EDIT_DELETE);
- i--;
- current = west;
- } else {
- edits.push(EDIT_ADD);
- j--;
- current = north;
- }
- }
-
- edits.reverse();
- return edits;
- },
-
- /**
- * Splice Projection functions:
- *
- * A splice map is a representation of how a previous array of items
- * was transformed into a new array of items. Conceptually it is a list of
- * tuples of
- *
- *
- *
- * which are kept in ascending index order of. The tuple represents that at
- * the |index|, |removed| sequence of items were removed, and counting forward
- * from |index|, |addedCount| items were added.
- */
-
- /**
- * Lacking individual splice mutation information, the minimal set of
- * splices can be synthesized given the previous state and final state of an
- * array. The basic approach is to calculate the edit distance matrix and
- * choose the shortest path through it.
- *
- * Complexity: O(l * p)
- * l: The length of the current array
- * p: The length of the old array
- */
- calcSplices: function(current, currentStart, currentEnd,
- old, oldStart, oldEnd) {
- var prefixCount = 0;
- var suffixCount = 0;
-
- var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
- if (currentStart == 0 && oldStart == 0)
- prefixCount = this.sharedPrefix(current, old, minLength);
-
- if (currentEnd == current.length && oldEnd == old.length)
- suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
-
- currentStart += prefixCount;
- oldStart += prefixCount;
- currentEnd -= suffixCount;
- oldEnd -= suffixCount;
-
- if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
- return [];
-
- if (currentStart == currentEnd) {
- var splice = newSplice(currentStart, [], 0);
- while (oldStart < oldEnd)
- splice.removed.push(old[oldStart++]);
-
- return [ splice ];
- } else if (oldStart == oldEnd)
- return [ newSplice(currentStart, [], currentEnd - currentStart) ];
-
- var ops = this.spliceOperationsFromEditDistances(
- this.calcEditDistances(current, currentStart, currentEnd,
- old, oldStart, oldEnd));
-
- var splice = undefined;
- var splices = [];
- var index = currentStart;
- var oldIndex = oldStart;
- for (var i = 0; i < ops.length; i++) {
- switch(ops[i]) {
- case EDIT_LEAVE:
- if (splice) {
- splices.push(splice);
- splice = undefined;
- }
-
- index++;
- oldIndex++;
- break;
- case EDIT_UPDATE:
- if (!splice)
- splice = newSplice(index, [], 0);
-
- splice.addedCount++;
- index++;
-
- splice.removed.push(old[oldIndex]);
- oldIndex++;
- break;
- case EDIT_ADD:
- if (!splice)
- splice = newSplice(index, [], 0);
-
- splice.addedCount++;
- index++;
- break;
- case EDIT_DELETE:
- if (!splice)
- splice = newSplice(index, [], 0);
-
- splice.removed.push(old[oldIndex]);
- oldIndex++;
- break;
- }
- }
-
- if (splice) {
- splices.push(splice);
- }
- return splices;
- },
-
- sharedPrefix: function(current, old, searchLength) {
- for (var i = 0; i < searchLength; i++)
- if (!this.equals(current[i], old[i]))
- return i;
- return searchLength;
- },
-
- sharedSuffix: function(current, old, searchLength) {
- var index1 = current.length;
- var index2 = old.length;
- var count = 0;
- while (count < searchLength && this.equals(current[--index1], old[--index2]))
- count++;
-
- return count;
- },
-
- calculateSplices: function(current, previous) {
- return this.calcSplices(current, 0, current.length, previous, 0,
- previous.length);
- },
-
- equals: function(currentValue, previousValue) {
- return currentValue === previousValue;
- }
- };
-
- // exports
- scope.ArraySplice = ArraySplice;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/MutationObserver.js b/src/ShadowDOM/MutationObserver.js
deleted file mode 100644
index ff6c56d..0000000
--- a/src/ShadowDOM/MutationObserver.js
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var setEndOfMicrotask = scope.setEndOfMicrotask
- var wrapIfNeeded = scope.wrapIfNeeded
- var wrappers = scope.wrappers;
-
- var registrationsTable = new WeakMap();
- var globalMutationObservers = [];
- var isScheduled = false;
-
- function scheduleCallback(observer) {
- if (observer.scheduled_)
- return;
-
- observer.scheduled_ = true;
- globalMutationObservers.push(observer);
-
- if (isScheduled)
- return;
- setEndOfMicrotask(notifyObservers);
- isScheduled = true;
- }
-
- // http://dom.spec.whatwg.org/#mutation-observers
- function notifyObservers() {
- isScheduled = false;
-
- while (globalMutationObservers.length) {
- var notifyList = globalMutationObservers;
- globalMutationObservers = [];
-
- // Deliver changes in birth order of the MutationObservers.
- notifyList.sort(function(x, y) { return x.uid_ - y.uid_; });
-
- for (var i = 0; i < notifyList.length; i++) {
- var mo = notifyList[i];
- mo.scheduled_ = false;
- var queue = mo.takeRecords();
- removeTransientObserversFor(mo);
- if (queue.length) {
- mo.callback_(queue, mo);
- }
- }
- }
- }
-
-
- /**
- * @param {string} type
- * @param {Node} target
- * @constructor
- */
- function MutationRecord(type, target) {
- this.type = type;
- this.target = target;
- this.addedNodes = new wrappers.NodeList();
- this.removedNodes = new wrappers.NodeList();
- this.previousSibling = null;
- this.nextSibling = null;
- this.attributeName = null;
- this.attributeNamespace = null;
- this.oldValue = null;
- }
-
- /**
- * Registers transient observers to ancestor and its ancesors for the node
- * which was removed.
- * @param {!Node} ancestor
- * @param {!Node} node
- */
- function registerTransientObservers(ancestor, node) {
- for (; ancestor; ancestor = ancestor.parentNode) {
- var registrations = registrationsTable.get(ancestor);
- if (!registrations)
- continue;
- for (var i = 0; i < registrations.length; i++) {
- var registration = registrations[i];
- if (registration.options.subtree)
- registration.addTransientObserver(node);
- }
- }
- }
-
- function removeTransientObserversFor(observer) {
- for (var i = 0; i < observer.nodes_.length; i++) {
- var node = observer.nodes_[i];
- var registrations = registrationsTable.get(node);
- if (!registrations)
- return;
- for (var j = 0; j < registrations.length; j++) {
- var registration = registrations[j];
- if (registration.observer === observer)
- registration.removeTransientObservers();
- }
- }
- }
-
- // http://dom.spec.whatwg.org/#queue-a-mutation-record
- function enqueueMutation(target, type, data) {
- // 1.
- var interestedObservers = Object.create(null);
- var associatedStrings = Object.create(null);
-
- // 2.
- for (var node = target; node; node = node.parentNode) {
- // 3.
- var registrations = registrationsTable.get(node);
- if (!registrations)
- continue;
- for (var j = 0; j < registrations.length; j++) {
- var registration = registrations[j];
- var options = registration.options;
- // 1.
- if (node !== target && !options.subtree)
- continue;
-
- // 2.
- if (type === 'attributes' && !options.attributes)
- continue;
-
- // 3. If type is "attributes", options's attributeFilter is present, and
- // either options's attributeFilter does not contain name or namespace
- // is non-null, continue.
- if (type === 'attributes' && options.attributeFilter &&
- (data.namespace !== null ||
- options.attributeFilter.indexOf(data.name) === -1)) {
- continue;
- }
-
- // 4.
- if (type === 'characterData' && !options.characterData)
- continue;
-
- // 5.
- if (type === 'childList' && !options.childList)
- continue;
-
- // 6.
- var observer = registration.observer;
- interestedObservers[observer.uid_] = observer;
-
- // 7. If either type is "attributes" and options's attributeOldValue is
- // true, or type is "characterData" and options's characterDataOldValue
- // is true, set the paired string of registered observer's observer in
- // interested observers to oldValue.
- if (type === 'attributes' && options.attributeOldValue ||
- type === 'characterData' && options.characterDataOldValue) {
- associatedStrings[observer.uid_] = data.oldValue;
- }
- }
- }
-
- // 4.
- for (var uid in interestedObservers) {
- var observer = interestedObservers[uid];
- var record = new MutationRecord(type, target);
-
- // 2.
- if ('name' in data && 'namespace' in data) {
- record.attributeName = data.name;
- record.attributeNamespace = data.namespace;
- }
-
- // 3.
- if (data.addedNodes)
- record.addedNodes = data.addedNodes;
-
- // 4.
- if (data.removedNodes)
- record.removedNodes = data.removedNodes;
-
- // 5.
- if (data.previousSibling)
- record.previousSibling = data.previousSibling;
-
- // 6.
- if (data.nextSibling)
- record.nextSibling = data.nextSibling;
-
- // 7.
- if (associatedStrings[uid] !== undefined)
- record.oldValue = associatedStrings[uid];
-
- // 8.
- scheduleCallback(observer);
- observer.records_.push(record);
- }
- }
-
- var slice = Array.prototype.slice;
-
- /**
- * @param {!Object} options
- * @constructor
- */
- function MutationObserverOptions(options) {
- this.childList = !!options.childList;
- this.subtree = !!options.subtree;
-
- // 1. If either options' attributeOldValue or attributeFilter is present
- // and options' attributes is omitted, set options' attributes to true.
- if (!('attributes' in options) &&
- ('attributeOldValue' in options || 'attributeFilter' in options)) {
- this.attributes = true;
- } else {
- this.attributes = !!options.attributes;
- }
-
- // 2. If options' characterDataOldValue is present and options'
- // characterData is omitted, set options' characterData to true.
- if ('characterDataOldValue' in options && !('characterData' in options))
- this.characterData = true;
- else
- this.characterData = !!options.characterData;
-
- // 3. & 4.
- if (!this.attributes &&
- (options.attributeOldValue || 'attributeFilter' in options) ||
- // 5.
- !this.characterData && options.characterDataOldValue) {
- throw new TypeError();
- }
-
- this.characterData = !!options.characterData;
- this.attributeOldValue = !!options.attributeOldValue;
- this.characterDataOldValue = !!options.characterDataOldValue;
- if ('attributeFilter' in options) {
- if (options.attributeFilter == null ||
- typeof options.attributeFilter !== 'object') {
- throw new TypeError();
- }
- this.attributeFilter = slice.call(options.attributeFilter);
- } else {
- this.attributeFilter = null;
- }
- }
-
- var uidCounter = 0;
-
- /**
- * The class that maps to the DOM MutationObserver interface.
- * @param {Function} callback.
- * @constructor
- */
- function MutationObserver(callback) {
- this.callback_ = callback;
- this.nodes_ = [];
- this.records_ = [];
- this.uid_ = ++uidCounter;
- this.scheduled_ = false;
- }
-
- MutationObserver.prototype = {
- constructor: MutationObserver,
-
- // http://dom.spec.whatwg.org/#dom-mutationobserver-observe
- observe: function(target, options) {
- target = wrapIfNeeded(target);
-
- var newOptions = new MutationObserverOptions(options);
-
- // 6.
- var registration;
- var registrations = registrationsTable.get(target);
- if (!registrations)
- registrationsTable.set(target, registrations = []);
-
- for (var i = 0; i < registrations.length; i++) {
- if (registrations[i].observer === this) {
- registration = registrations[i];
- // 6.1.
- registration.removeTransientObservers();
- // 6.2.
- registration.options = newOptions;
- }
- }
-
- // 7.
- if (!registration) {
- registration = new Registration(this, target, newOptions);
- registrations.push(registration);
- this.nodes_.push(target);
- }
- },
-
- // http://dom.spec.whatwg.org/#dom-mutationobserver-disconnect
- disconnect: function() {
- this.nodes_.forEach(function(node) {
- var registrations = registrationsTable.get(node);
- for (var i = 0; i < registrations.length; i++) {
- var registration = registrations[i];
- if (registration.observer === this) {
- registrations.splice(i, 1);
- // Each node can only have one registered observer associated with
- // this observer.
- break;
- }
- }
- }, this);
- this.records_ = [];
- },
-
- takeRecords: function() {
- var copyOfRecords = this.records_;
- this.records_ = [];
- return copyOfRecords;
- }
- };
-
- /**
- * Class used to represent a registered observer.
- * @param {MutationObserver} observer
- * @param {Node} target
- * @param {MutationObserverOptions} options
- * @constructor
- */
- function Registration(observer, target, options) {
- this.observer = observer;
- this.target = target;
- this.options = options;
- this.transientObservedNodes = [];
- }
-
- Registration.prototype = {
- /**
- * Adds a transient observer on node. The transient observer gets removed
- * next time we deliver the change records.
- * @param {Node} node
- */
- addTransientObserver: function(node) {
- // Don't add transient observers on the target itself. We already have all
- // the required listeners set up on the target.
- if (node === this.target)
- return;
-
- // Make sure we remove transient observers at the end of microtask, even
- // if we didn't get any change records.
- scheduleCallback(this.observer);
-
- this.transientObservedNodes.push(node);
- var registrations = registrationsTable.get(node);
- if (!registrations)
- registrationsTable.set(node, registrations = []);
-
- // We know that registrations does not contain this because we already
- // checked if node === this.target.
- registrations.push(this);
- },
-
- removeTransientObservers: function() {
- var transientObservedNodes = this.transientObservedNodes;
- this.transientObservedNodes = [];
-
- for (var i = 0; i < transientObservedNodes.length; i++) {
- var node = transientObservedNodes[i];
- var registrations = registrationsTable.get(node);
- for (var j = 0; j < registrations.length; j++) {
- if (registrations[j] === this) {
- registrations.splice(j, 1);
- // Each node can only have one registered observer associated with
- // this observer.
- break;
- }
- }
- }
- }
- };
-
- scope.enqueueMutation = enqueueMutation;
- scope.registerTransientObservers = registerTransientObservers;
- scope.wrappers.MutationObserver = MutationObserver;
- scope.wrappers.MutationRecord = MutationRecord;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/ShadowDOM.js b/src/ShadowDOM/ShadowDOM.js
deleted file mode 100644
index 63ff209..0000000
--- a/src/ShadowDOM/ShadowDOM.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function() {
-
-var thisFile = 'ShadowDOM.js';
-var base = '';
-Array.prototype.forEach.call(document.querySelectorAll('script[src]'), function(s) {
- var src = s.getAttribute('src');
- var re = new RegExp(thisFile + '[^\\\\]*');
- var match = src.match(re);
- if (match) {
- base = src.slice(0, -match[0].length);
- }
-});
-
-[
- '../WeakMap/WeakMap.js',
- 'wrappers.js',
- 'ArraySplice.js',
- 'microtask.js',
- 'MutationObserver.js',
- 'TreeScope.js',
- 'wrappers/events.js',
- 'wrappers/TouchEvent.js',
- 'wrappers/NodeList.js',
- 'wrappers/HTMLCollection.js',
- 'wrappers/Node.js',
- 'querySelector.js',
- 'wrappers/node-interfaces.js',
- 'wrappers/CharacterData.js',
- 'wrappers/Text.js',
- 'wrappers/DOMTokenList.js',
- 'wrappers/Element.js',
- 'wrappers/HTMLElement.js',
- 'wrappers/HTMLCanvasElement.js',
- 'wrappers/HTMLContentElement.js',
- 'wrappers/HTMLFormElement.js',
- 'wrappers/HTMLImageElement.js',
- 'wrappers/HTMLShadowElement.js',
- 'wrappers/HTMLTemplateElement.js',
- 'wrappers/HTMLMediaElement.js',
- 'wrappers/HTMLAudioElement.js',
- 'wrappers/HTMLOptionElement.js',
- 'wrappers/HTMLSelectElement.js',
- 'wrappers/HTMLTableElement.js',
- 'wrappers/HTMLTableSectionElement.js',
- 'wrappers/HTMLTableRowElement.js',
- 'wrappers/HTMLUnknownElement.js',
- 'wrappers/SVGElement.js',
- 'wrappers/SVGUseElement.js',
- 'wrappers/SVGElementInstance.js',
- 'wrappers/CanvasRenderingContext2D.js',
- 'wrappers/WebGLRenderingContext.js',
- 'wrappers/generic.js',
- 'wrappers/ShadowRoot.js',
- 'wrappers/Range.js',
- 'ShadowRenderer.js',
- 'wrappers/elements-with-form-property.js',
- 'wrappers/Selection.js',
- 'wrappers/TreeWalker.js',
- 'wrappers/Document.js',
- 'wrappers/Window.js',
- 'wrappers/DataTransfer.js',
- 'wrappers/FormData.js',
- 'wrappers/XMLHttpRequest.js',
- 'wrappers/override-constructors.js'
-].forEach(function(src) {
- document.write('');
-});
-
-})();
diff --git a/src/ShadowDOM/ShadowRenderer.js b/src/ShadowDOM/ShadowRenderer.js
deleted file mode 100644
index cd3d22e..0000000
--- a/src/ShadowDOM/ShadowRenderer.js
+++ /dev/null
@@ -1,671 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var Element = scope.wrappers.Element;
- var HTMLContentElement = scope.wrappers.HTMLContentElement;
- var HTMLShadowElement = scope.wrappers.HTMLShadowElement;
- var Node = scope.wrappers.Node;
- var ShadowRoot = scope.wrappers.ShadowRoot;
- var assert = scope.assert;
- var getTreeScope = scope.getTreeScope;
- var mixin = scope.mixin;
- var oneOf = scope.oneOf;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
- var ArraySplice = scope.ArraySplice;
-
- /**
- * Updates the fields of a wrapper to a snapshot of the logical DOM as needed.
- * Up means parentNode
- * Sideways means previous and next sibling.
- * @param {!Node} wrapper
- */
- function updateWrapperUpAndSideways(wrapper) {
- wrapper.previousSibling_ = wrapper.previousSibling;
- wrapper.nextSibling_ = wrapper.nextSibling;
- wrapper.parentNode_ = wrapper.parentNode;
- }
-
- /**
- * Updates the fields of a wrapper to a snapshot of the logical DOM as needed.
- * Down means first and last child
- * @param {!Node} wrapper
- */
- function updateWrapperDown(wrapper) {
- wrapper.firstChild_ = wrapper.firstChild;
- wrapper.lastChild_ = wrapper.lastChild;
- }
-
- function updateAllChildNodes(parentNodeWrapper) {
- assert(parentNodeWrapper instanceof Node);
- for (var childWrapper = parentNodeWrapper.firstChild;
- childWrapper;
- childWrapper = childWrapper.nextSibling) {
- updateWrapperUpAndSideways(childWrapper);
- }
- updateWrapperDown(parentNodeWrapper);
- }
-
- function insertBefore(parentNodeWrapper, newChildWrapper, refChildWrapper) {
- var parentNode = unwrap(parentNodeWrapper);
- var newChild = unwrap(newChildWrapper);
- var refChild = refChildWrapper ? unwrap(refChildWrapper) : null;
-
- remove(newChildWrapper);
- updateWrapperUpAndSideways(newChildWrapper);
-
- if (!refChildWrapper) {
- parentNodeWrapper.lastChild_ = parentNodeWrapper.lastChild;
- if (parentNodeWrapper.lastChild === parentNodeWrapper.firstChild)
- parentNodeWrapper.firstChild_ = parentNodeWrapper.firstChild;
-
- var lastChildWrapper = wrap(parentNode.lastChild);
- if (lastChildWrapper)
- lastChildWrapper.nextSibling_ = lastChildWrapper.nextSibling;
- } else {
- if (parentNodeWrapper.firstChild === refChildWrapper)
- parentNodeWrapper.firstChild_ = refChildWrapper;
-
- refChildWrapper.previousSibling_ = refChildWrapper.previousSibling;
- }
-
- scope.originalInsertBefore.call(parentNode, newChild, refChild);
- }
-
- function remove(nodeWrapper) {
- var node = unwrap(nodeWrapper)
- var parentNode = node.parentNode;
- if (!parentNode)
- return;
-
- var parentNodeWrapper = wrap(parentNode);
- updateWrapperUpAndSideways(nodeWrapper);
-
- if (nodeWrapper.previousSibling)
- nodeWrapper.previousSibling.nextSibling_ = nodeWrapper;
- if (nodeWrapper.nextSibling)
- nodeWrapper.nextSibling.previousSibling_ = nodeWrapper;
-
- if (parentNodeWrapper.lastChild === nodeWrapper)
- parentNodeWrapper.lastChild_ = nodeWrapper;
- if (parentNodeWrapper.firstChild === nodeWrapper)
- parentNodeWrapper.firstChild_ = nodeWrapper;
-
- scope.originalRemoveChild.call(parentNode, node);
- }
-
- var distributedNodesTable = new WeakMap();
- var destinationInsertionPointsTable = new WeakMap();
- var rendererForHostTable = new WeakMap();
-
- function resetDistributedNodes(insertionPoint) {
- distributedNodesTable.set(insertionPoint, []);
- }
-
- function getDistributedNodes(insertionPoint) {
- var rv = distributedNodesTable.get(insertionPoint);
- if (!rv)
- distributedNodesTable.set(insertionPoint, rv = []);
- return rv;
- }
-
- function getChildNodesSnapshot(node) {
- var result = [], i = 0;
- for (var child = node.firstChild; child; child = child.nextSibling) {
- result[i++] = child;
- }
- return result;
- }
-
- var request = oneOf(window, [
- 'requestAnimationFrame',
- 'mozRequestAnimationFrame',
- 'webkitRequestAnimationFrame',
- 'setTimeout'
- ]);
-
- var pendingDirtyRenderers = [];
- var renderTimer;
-
- function renderAllPending() {
- // TODO(arv): Order these in document order. That way we do not have to
- // render something twice.
- for (var i = 0; i < pendingDirtyRenderers.length; i++) {
- var renderer = pendingDirtyRenderers[i];
- var parentRenderer = renderer.parentRenderer;
- if (parentRenderer && parentRenderer.dirty)
- continue;
- renderer.render();
- }
-
- pendingDirtyRenderers = [];
- }
-
- function handleRequestAnimationFrame() {
- renderTimer = null;
- renderAllPending();
- }
-
- /**
- * Returns existing shadow renderer for a host or creates it if it is needed.
- * @params {!Element} host
- * @return {!ShadowRenderer}
- */
- function getRendererForHost(host) {
- var renderer = rendererForHostTable.get(host);
- if (!renderer) {
- renderer = new ShadowRenderer(host);
- rendererForHostTable.set(host, renderer);
- }
- return renderer;
- }
-
- function getShadowRootAncestor(node) {
- var root = getTreeScope(node).root;
- if (root instanceof ShadowRoot)
- return root;
- return null;
- }
-
- function getRendererForShadowRoot(shadowRoot) {
- return getRendererForHost(shadowRoot.host);
- }
-
- var spliceDiff = new ArraySplice();
- spliceDiff.equals = function(renderNode, rawNode) {
- return unwrap(renderNode.node) === rawNode;
- };
-
- /**
- * RenderNode is used as an in memory "render tree". When we render the
- * composed tree we create a tree of RenderNodes, then we diff this against
- * the real DOM tree and make minimal changes as needed.
- */
- function RenderNode(node) {
- this.skip = false;
- this.node = node;
- this.childNodes = [];
- }
-
- RenderNode.prototype = {
- append: function(node) {
- var rv = new RenderNode(node);
- this.childNodes.push(rv);
- return rv;
- },
-
- sync: function(opt_added) {
- if (this.skip)
- return;
-
- var nodeWrapper = this.node;
- // plain array of RenderNodes
- var newChildren = this.childNodes;
- // plain array of real nodes.
- var oldChildren = getChildNodesSnapshot(unwrap(nodeWrapper));
- var added = opt_added || new WeakMap();
-
- var splices = spliceDiff.calculateSplices(newChildren, oldChildren);
-
- var newIndex = 0, oldIndex = 0;
- var lastIndex = 0;
- for (var i = 0; i < splices.length; i++) {
- var splice = splices[i];
- for (; lastIndex < splice.index; lastIndex++) {
- oldIndex++;
- newChildren[newIndex++].sync(added);
- }
-
- var removedCount = splice.removed.length;
- for (var j = 0; j < removedCount; j++) {
- var wrapper = wrap(oldChildren[oldIndex++]);
- if (!added.get(wrapper))
- remove(wrapper);
- }
-
- var addedCount = splice.addedCount;
- var refNode = oldChildren[oldIndex] && wrap(oldChildren[oldIndex]);
- for (var j = 0; j < addedCount; j++) {
- var newChildRenderNode = newChildren[newIndex++];
- var newChildWrapper = newChildRenderNode.node;
- insertBefore(nodeWrapper, newChildWrapper, refNode);
-
- // Keep track of added so that we do not remove the node after it
- // has been added.
- added.set(newChildWrapper, true);
-
- newChildRenderNode.sync(added);
- }
-
- lastIndex += addedCount;
- }
-
- for (var i = lastIndex; i < newChildren.length; i++) {
- newChildren[i].sync(added);
- }
- }
- };
-
- function ShadowRenderer(host) {
- this.host = host;
- this.dirty = false;
- this.invalidateAttributes();
- this.associateNode(host);
- }
-
- ShadowRenderer.prototype = {
-
- // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#rendering-shadow-trees
- render: function(opt_renderNode) {
- if (!this.dirty)
- return;
-
- this.invalidateAttributes();
-
- var host = this.host;
-
- this.distribution(host);
- var renderNode = opt_renderNode || new RenderNode(host);
- this.buildRenderTree(renderNode, host);
-
- var topMostRenderer = !opt_renderNode;
- if (topMostRenderer)
- renderNode.sync();
-
- this.dirty = false;
- },
-
- get parentRenderer() {
- return getTreeScope(this.host).renderer;
- },
-
- invalidate: function() {
- if (!this.dirty) {
- this.dirty = true;
- var parentRenderer = this.parentRenderer;
- if (parentRenderer)
- parentRenderer.invalidate();
- pendingDirtyRenderers.push(this);
- if (renderTimer)
- return;
- renderTimer = window[request](handleRequestAnimationFrame, 0);
- }
- },
-
- // http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms
- distribution: function(root) {
- this.resetAllSubtrees(root);
- this.distributionResolution(root);
- },
-
- resetAll: function(node) {
- if (isInsertionPoint(node))
- resetDistributedNodes(node);
- else
- resetDestinationInsertionPoints(node);
-
- this.resetAllSubtrees(node);
- },
-
- resetAllSubtrees: function(node) {
- for (var child = node.firstChild; child; child = child.nextSibling) {
- this.resetAll(child);
- }
-
- if (node.shadowRoot)
- this.resetAll(node.shadowRoot);
-
- if (node.olderShadowRoot)
- this.resetAll(node.olderShadowRoot);
- },
-
- // http://w3c.github.io/webcomponents/spec/shadow/#distribution-results
- distributionResolution: function(node) {
- if (isShadowHost(node)) {
- var shadowHost = node;
- // 1.1
- var pool = poolPopulation(shadowHost);
-
- var shadowTrees = getShadowTrees(shadowHost);
-
- // 1.2
- for (var i = 0; i < shadowTrees.length; i++) {
- // 1.2.1
- this.poolDistribution(shadowTrees[i], pool);
- }
-
- // 1.3
- for (var i = shadowTrees.length - 1; i >= 0; i--) {
- var shadowTree = shadowTrees[i];
-
- // 1.3.1
- // TODO(arv): We should keep the shadow insertion points on the
- // shadow root (or renderer) so we don't have to search the tree
- // every time.
- var shadow = getShadowInsertionPoint(shadowTree);
-
- // 1.3.2
- if (shadow) {
-
- // 1.3.2.1
- var olderShadowRoot = shadowTree.olderShadowRoot;
- if (olderShadowRoot) {
- // 1.3.2.1.1
- pool = poolPopulation(olderShadowRoot);
- }
-
- // 1.3.2.2
- for (var j = 0; j < pool.length; j++) {
- // 1.3.2.2.1
- destributeNodeInto(pool[j], shadow);
- }
- }
-
- // 1.3.3
- this.distributionResolution(shadowTree);
- }
- }
-
- for (var child = node.firstChild; child; child = child.nextSibling) {
- this.distributionResolution(child);
- }
- },
-
- // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-distribution-algorithm
- poolDistribution: function (node, pool) {
- if (node instanceof HTMLShadowElement)
- return;
-
- if (node instanceof HTMLContentElement) {
- var content = node;
- this.updateDependentAttributes(content.getAttribute('select'));
-
- var anyDistributed = false;
-
- // 1.1
- for (var i = 0; i < pool.length; i++) {
- var node = pool[i];
- if (!node)
- continue;
- if (matches(node, content)) {
- destributeNodeInto(node, content);
- pool[i] = undefined;
- anyDistributed = true;
- }
- }
-
- // 1.2
- // Fallback content
- if (!anyDistributed) {
- for (var child = content.firstChild;
- child;
- child = child.nextSibling) {
- destributeNodeInto(child, content);
- }
- }
-
- return;
- }
-
- for (var child = node.firstChild; child; child = child.nextSibling) {
- this.poolDistribution(child, pool);
- }
- },
-
- buildRenderTree: function(renderNode, node) {
- var children = this.compose(node);
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- var childRenderNode = renderNode.append(child);
- this.buildRenderTree(childRenderNode, child);
- }
-
- if (isShadowHost(node)) {
- var renderer = getRendererForHost(node);
- renderer.dirty = false;
- }
-
- },
-
- compose: function(node) {
- var children = [];
- var p = node.shadowRoot || node;
- for (var child = p.firstChild; child; child = child.nextSibling) {
- if (isInsertionPoint(child)) {
- this.associateNode(p);
- var distributedNodes = getDistributedNodes(child);
- for (var j = 0; j < distributedNodes.length; j++) {
- var distributedNode = distributedNodes[j];
- if (isFinalDestination(child, distributedNode))
- children.push(distributedNode);
- }
- } else {
- children.push(child);
- }
- }
- return children;
- },
-
- /**
- * Invalidates the attributes used to keep track of which attributes may
- * cause the renderer to be invalidated.
- */
- invalidateAttributes: function() {
- this.attributes = Object.create(null);
- },
-
- /**
- * Parses the selector and makes this renderer dependent on the attribute
- * being used in the selector.
- * @param {string} selector
- */
- updateDependentAttributes: function(selector) {
- if (!selector)
- return;
-
- var attributes = this.attributes;
-
- // .class
- if (/\.\w+/.test(selector))
- attributes['class'] = true;
-
- // #id
- if (/#\w+/.test(selector))
- attributes['id'] = true;
-
- selector.replace(/\[\s*([^\s=\|~\]]+)/g, function(_, name) {
- attributes[name] = true;
- });
-
- // Pseudo selectors have been removed from the spec.
- },
-
- dependsOnAttribute: function(name) {
- return this.attributes[name];
- },
-
- associateNode: function(node) {
- unsafeUnwrap(node).polymerShadowRenderer_ = this;
- }
- };
-
- // http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-population-algorithm
- function poolPopulation(node) {
- var pool = [];
- for (var child = node.firstChild; child; child = child.nextSibling) {
- if (isInsertionPoint(child)) {
- pool.push.apply(pool, getDistributedNodes(child));
- } else {
- pool.push(child);
- }
- }
- return pool;
- }
-
- function getShadowInsertionPoint(node) {
- if (node instanceof HTMLShadowElement)
- return node;
- if (node instanceof HTMLContentElement)
- return null;
- for (var child = node.firstChild; child; child = child.nextSibling) {
- var res = getShadowInsertionPoint(child);
- if (res)
- return res;
- }
- return null;
- }
-
- function destributeNodeInto(child, insertionPoint) {
- getDistributedNodes(insertionPoint).push(child);
- var points = destinationInsertionPointsTable.get(child);
- if (!points)
- destinationInsertionPointsTable.set(child, [insertionPoint]);
- else
- points.push(insertionPoint);
- }
-
- function getDestinationInsertionPoints(node) {
- return destinationInsertionPointsTable.get(node);
- }
-
- function resetDestinationInsertionPoints(node) {
- // IE11 crashes when delete is used.
- destinationInsertionPointsTable.set(node, undefined);
- }
-
- // AllowedSelectors :
- // TypeSelector
- // *
- // ClassSelector
- // IDSelector
- // AttributeSelector
- // negation
- var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/;
-
- function matches(node, contentElement) {
- var select = contentElement.getAttribute('select');
- if (!select)
- return true;
-
- // Here we know the select attribute is a non empty string.
- select = select.trim();
- if (!select)
- return true;
-
- if (!(node instanceof Element))
- return false;
-
- if (!selectorStartCharRe.test(select))
- return false;
-
- try {
- return node.matches(select);
- } catch (ex) {
- // Invalid selector.
- return false;
- }
- }
-
- function isFinalDestination(insertionPoint, node) {
- var points = getDestinationInsertionPoints(node);
- return points && points[points.length - 1] === insertionPoint;
- }
-
- function isInsertionPoint(node) {
- return node instanceof HTMLContentElement ||
- node instanceof HTMLShadowElement;
- }
-
- function isShadowHost(shadowHost) {
- return shadowHost.shadowRoot;
- }
-
- // Returns the shadow trees as an array, with the youngest tree at the
- // beginning of the array.
- function getShadowTrees(host) {
- var trees = [];
-
- for (var tree = host.shadowRoot; tree; tree = tree.olderShadowRoot) {
- trees.push(tree);
- }
- return trees;
- }
-
- function render(host) {
- new ShadowRenderer(host).render();
- };
-
- // Need to rerender shadow host when:
- //
- // - a direct child to the ShadowRoot is added or removed
- // - a direct child to the host is added or removed
- // - a new shadow root is created
- // - a direct child to a content/shadow element is added or removed
- // - a sibling to a content/shadow element is added or removed
- // - content[select] is changed
- // - an attribute in a direct child to a host is modified
-
- /**
- * This gets called when a node was added or removed to it.
- */
- Node.prototype.invalidateShadowRenderer = function(force) {
- var renderer = unsafeUnwrap(this).polymerShadowRenderer_;
- if (renderer) {
- renderer.invalidate();
- return true;
- }
-
- return false;
- };
-
- HTMLContentElement.prototype.getDistributedNodes =
- HTMLShadowElement.prototype.getDistributedNodes = function() {
- // TODO(arv): We should only rerender the dirty ancestor renderers (from
- // the root and down).
- renderAllPending();
- return getDistributedNodes(this);
- };
-
- Element.prototype.getDestinationInsertionPoints = function() {
- renderAllPending();
- return getDestinationInsertionPoints(this) || [];
- };
-
- HTMLContentElement.prototype.nodeIsInserted_ =
- HTMLShadowElement.prototype.nodeIsInserted_ = function() {
- // Invalidate old renderer if any.
- this.invalidateShadowRenderer();
-
- var shadowRoot = getShadowRootAncestor(this);
- var renderer;
- if (shadowRoot)
- renderer = getRendererForShadowRoot(shadowRoot);
- unsafeUnwrap(this).polymerShadowRenderer_ = renderer;
- if (renderer)
- renderer.invalidate();
- };
-
- scope.getRendererForHost = getRendererForHost;
- scope.getShadowTrees = getShadowTrees;
- scope.renderAllPending = renderAllPending;
-
- scope.getDestinationInsertionPoints = getDestinationInsertionPoints;
-
- // Exposed for testing
- scope.visual = {
- insertBefore: insertBefore,
- remove: remove,
- };
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/TreeScope.js b/src/ShadowDOM/TreeScope.js
deleted file mode 100644
index 07011a7..0000000
--- a/src/ShadowDOM/TreeScope.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- /**
- * A tree scope represents the root of a tree. All nodes in a tree point to
- * the same TreeScope object. The tree scope of a node get set the first time
- * it is accessed or when a node is added or remove to a tree.
- *
- * The root is a Node that has no parent.
- *
- * The parent is another TreeScope. For ShadowRoots, it is the TreeScope of
- * the host of the ShadowRoot.
- *
- * @param {!Node} root
- * @param {TreeScope} parent
- * @constructor
- */
- function TreeScope(root, parent) {
- /** @type {!Node} */
- this.root = root;
-
- /** @type {TreeScope} */
- this.parent = parent;
- }
-
- TreeScope.prototype = {
- get renderer() {
- if (this.root instanceof scope.wrappers.ShadowRoot) {
- return scope.getRendererForHost(this.root.host);
- }
- return null;
- },
-
- contains: function(treeScope) {
- for (; treeScope; treeScope = treeScope.parent) {
- if (treeScope === this)
- return true;
- }
- return false;
- }
- };
-
- function setTreeScope(node, treeScope) {
- if (node.treeScope_ !== treeScope) {
- node.treeScope_ = treeScope;
- for (var sr = node.shadowRoot; sr; sr = sr.olderShadowRoot) {
- sr.treeScope_.parent = treeScope;
- }
- for (var child = node.firstChild; child; child = child.nextSibling) {
- setTreeScope(child, treeScope);
- }
- }
- }
-
- function getTreeScope(node) {
- if (node instanceof scope.wrappers.Window) {
- debugger;
- }
-
- if (node.treeScope_)
- return node.treeScope_;
- var parent = node.parentNode;
- var treeScope;
- if (parent)
- treeScope = getTreeScope(parent);
- else
- treeScope = new TreeScope(node, null);
- return node.treeScope_ = treeScope;
- }
-
- scope.TreeScope = TreeScope;
- scope.getTreeScope = getTreeScope;
- scope.setTreeScope = setTreeScope;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/build.json b/src/ShadowDOM/build.json
deleted file mode 100644
index f0e6767..0000000
--- a/src/ShadowDOM/build.json
+++ /dev/null
@@ -1,52 +0,0 @@
-[
- "../WeakMap/WeakMap.js",
- "wrappers.js",
- "ArraySplice.js",
- "microtask.js",
- "MutationObserver.js",
- "TreeScope.js",
- "wrappers/events.js",
- "wrappers/TouchEvent.js",
- "wrappers/NodeList.js",
- "wrappers/HTMLCollection.js",
- "wrappers/Node.js",
- "querySelector.js",
- "wrappers/node-interfaces.js",
- "wrappers/CharacterData.js",
- "wrappers/Text.js",
- "wrappers/DOMTokenList.js",
- "wrappers/Element.js",
- "wrappers/HTMLElement.js",
- "wrappers/HTMLCanvasElement.js",
- "wrappers/HTMLContentElement.js",
- "wrappers/HTMLFormElement.js",
- "wrappers/HTMLImageElement.js",
- "wrappers/HTMLShadowElement.js",
- "wrappers/HTMLTemplateElement.js",
- "wrappers/HTMLMediaElement.js",
- "wrappers/HTMLAudioElement.js",
- "wrappers/HTMLOptionElement.js",
- "wrappers/HTMLSelectElement.js",
- "wrappers/HTMLTableElement.js",
- "wrappers/HTMLTableSectionElement.js",
- "wrappers/HTMLTableRowElement.js",
- "wrappers/HTMLUnknownElement.js",
- "wrappers/SVGElement.js",
- "wrappers/SVGUseElement.js",
- "wrappers/SVGElementInstance.js",
- "wrappers/CanvasRenderingContext2D.js",
- "wrappers/WebGLRenderingContext.js",
- "wrappers/generic.js",
- "wrappers/ShadowRoot.js",
- "wrappers/Range.js",
- "ShadowRenderer.js",
- "wrappers/elements-with-form-property.js",
- "wrappers/Selection.js",
- "wrappers/TreeWalker.js",
- "wrappers/Document.js",
- "wrappers/Window.js",
- "wrappers/DataTransfer.js",
- "wrappers/FormData.js",
- "wrappers/XMLHttpRequest.js",
- "wrappers/override-constructors.js"
-]
diff --git a/src/ShadowDOM/microtask.js b/src/ShadowDOM/microtask.js
deleted file mode 100644
index 31e7246..0000000
--- a/src/ShadowDOM/microtask.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(context) {
- 'use strict';
-
- var OriginalMutationObserver = window.MutationObserver;
- var callbacks = [];
- var pending = false;
- var timerFunc;
-
- function handle() {
- pending = false;
- var copies = callbacks.slice(0);
- callbacks = [];
- for (var i = 0; i < copies.length; i++) {
- (0, copies[i])();
- }
- }
-
- if (OriginalMutationObserver) {
- var counter = 1;
- var observer = new OriginalMutationObserver(handle);
- var textNode = document.createTextNode(counter);
- observer.observe(textNode, {characterData: true});
-
- timerFunc = function() {
- counter = (counter + 1) % 2;
- textNode.data = counter;
- };
-
- } else {
- timerFunc = window.setTimeout;
- }
-
- function setEndOfMicrotask(func) {
- callbacks.push(func);
- if (pending)
- return;
- pending = true;
- timerFunc(handle, 0);
- }
-
- context.setEndOfMicrotask = setEndOfMicrotask;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/querySelector.js b/src/ShadowDOM/querySelector.js
deleted file mode 100644
index adf7364..0000000
--- a/src/ShadowDOM/querySelector.js
+++ /dev/null
@@ -1,308 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLCollection = scope.wrappers.HTMLCollection;
- var NodeList = scope.wrappers.NodeList;
- var getTreeScope = scope.getTreeScope;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
-
- var originalDocumentQuerySelector = document.querySelector;
- var originalElementQuerySelector = document.documentElement.querySelector;
-
- var originalDocumentQuerySelectorAll = document.querySelectorAll;
- var originalElementQuerySelectorAll = document.documentElement.querySelectorAll;
-
- var originalDocumentGetElementsByTagName = document.getElementsByTagName;
- var originalElementGetElementsByTagName = document.documentElement.getElementsByTagName;
-
- var originalDocumentGetElementsByTagNameNS = document.getElementsByTagNameNS;
- var originalElementGetElementsByTagNameNS = document.documentElement.getElementsByTagNameNS;
-
- var OriginalElement = window.Element;
- var OriginalDocument = window.HTMLDocument || window.Document;
-
- function filterNodeList(list, index, result, deep) {
- var wrappedItem = null;
- var root = null;
- for (var i = 0, length = list.length; i < length; i++) {
- wrappedItem = wrap(list[i]);
- if (!deep && (root = getTreeScope(wrappedItem).root)) {
- if (root instanceof scope.wrappers.ShadowRoot) {
- continue;
- }
- }
- result[index++] = wrappedItem;
- }
-
- return index;
- }
-
- function shimSelector(selector) {
- return String(selector).replace(/\/deep\/|::shadow|>>>/g, ' ');
- }
-
- function shimMatchesSelector(selector) {
- return String(selector)
- // Transform `:host(selector)` to `selector`
- .replace(
- /:host\(([^\s]+)\)/g,
- '$1'
- )
- // Transform `selector:host` to `selector`
- .replace(
- /([^\s]):host/g,
- '$1'
- )
- // Transform `:host` to `*`
- .replace(
- ':host',
- '*'
- )
- // From ShadowCSS, will be replaced by space
- .replace(
- /\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content|>>>/g,
- ' '
- );
- }
-
- function findOne(node, selector) {
- var m, el = node.firstElementChild;
- while (el) {
- if (el.matches(selector))
- return el;
- m = findOne(el, selector);
- if (m)
- return m;
- el = el.nextElementSibling;
- }
- return null;
- }
-
- function matchesSelector(el, selector) {
- return el.matches(selector);
- }
-
- var XHTML_NS = 'http://www.w3.org/1999/xhtml';
-
- function matchesTagName(el, localName, localNameLowerCase) {
- var ln = el.localName;
- return ln === localName ||
- ln === localNameLowerCase && el.namespaceURI === XHTML_NS;
- }
-
- function matchesEveryThing() {
- return true;
- }
-
- function matchesLocalNameOnly(el, ns, localName) {
- return el.localName === localName;
- }
-
- function matchesNameSpace(el, ns) {
- return el.namespaceURI === ns;
- }
-
- function matchesLocalNameNS(el, ns, localName) {
- return el.namespaceURI === ns && el.localName === localName;
- }
-
- function findElements(node, index, result, p, arg0, arg1) {
- var el = node.firstElementChild;
- while (el) {
- if (p(el, arg0, arg1))
- result[index++] = el;
- index = findElements(el, index, result, p, arg0, arg1);
- el = el.nextElementSibling;
- }
- return index;
- }
-
- // find and findAll will only match Simple Selectors,
- // Structural Pseudo Classes are not guaranteed to be correct
- // http://www.w3.org/TR/css3-selectors/#simple-selectors
-
- function querySelectorAllFiltered(p, index, result, selector, deep) {
- var target = unsafeUnwrap(this);
- var list;
- var root = getTreeScope(this).root;
- if (root instanceof scope.wrappers.ShadowRoot) {
- // We are in the shadow tree and the logical tree is
- // going to be disconnected so we do a manual tree traversal
- return findElements(this, index, result, p, selector, null);
- } else if (target instanceof OriginalElement) {
- list = originalElementQuerySelectorAll.call(target, selector);
- } else if (target instanceof OriginalDocument) {
- list = originalDocumentQuerySelectorAll.call(target, selector);
- } else {
- // When we get a ShadowRoot the logical tree is going to be disconnected
- // so we do a manual tree traversal
- return findElements(this, index, result, p, selector, null);
- }
-
- return filterNodeList(list, index, result, deep);
- }
-
- var SelectorsInterface = {
- querySelector: function(selector) {
- var shimmed = shimSelector(selector);
- var deep = shimmed !== selector;
- selector = shimmed;
-
- var target = unsafeUnwrap(this);
- var wrappedItem;
- var root = getTreeScope(this).root;
- if (root instanceof scope.wrappers.ShadowRoot) {
- // We are in the shadow tree and the logical tree is
- // going to be disconnected so we do a manual tree traversal
- return findOne(this, selector);
- } else if (target instanceof OriginalElement) {
- wrappedItem = wrap(originalElementQuerySelector.call(target, selector));
- } else if (target instanceof OriginalDocument) {
- wrappedItem = wrap(originalDocumentQuerySelector.call(target, selector));
- } else {
- // When we get a ShadowRoot the logical tree is going to be disconnected
- // so we do a manual tree traversal
- return findOne(this, selector);
- }
-
- if (!wrappedItem) {
- // When the original query returns nothing
- // we return nothing (to be consistent with the other wrapped calls)
- return wrappedItem;
- } else if (!deep && (root = getTreeScope(wrappedItem).root)) {
- if (root instanceof scope.wrappers.ShadowRoot) {
- // When the original query returns an element in the ShadowDOM
- // we must do a manual tree traversal
- return findOne(this, selector);
- }
- }
-
- return wrappedItem;
- },
- querySelectorAll: function(selector) {
- var shimmed = shimSelector(selector);
- var deep = shimmed !== selector;
- selector = shimmed;
-
- var result = new NodeList();
-
- result.length = querySelectorAllFiltered.call(this,
- matchesSelector,
- 0,
- result,
- selector,
- deep);
-
- return result;
- }
- };
-
- var MatchesInterface = {
- matches: function(selector) {
- selector = shimMatchesSelector(selector);
- return scope.originalMatches.call(unsafeUnwrap(this), selector);
- }
- };
-
- function getElementsByTagNameFiltered(p, index, result, localName,
- lowercase) {
- var target = unsafeUnwrap(this);
- var list;
- var root = getTreeScope(this).root;
- if (root instanceof scope.wrappers.ShadowRoot) {
- // We are in the shadow tree and the logical tree is
- // going to be disconnected so we do a manual tree traversal
- return findElements(this, index, result, p, localName, lowercase);
- } else if (target instanceof OriginalElement) {
- list = originalElementGetElementsByTagName.call(target, localName,
- lowercase);
- } else if (target instanceof OriginalDocument) {
- list = originalDocumentGetElementsByTagName.call(target, localName,
- lowercase);
- } else {
- // When we get a ShadowRoot the logical tree is going to be disconnected
- // so we do a manual tree traversal
- return findElements(this, index, result, p, localName, lowercase);
- }
-
- return filterNodeList(list, index, result, false);
- }
-
- function getElementsByTagNameNSFiltered(p, index, result, ns, localName) {
- var target = unsafeUnwrap(this);
- var list;
- var root = getTreeScope(this).root;
- if (root instanceof scope.wrappers.ShadowRoot) {
- // We are in the shadow tree and the logical tree is
- // going to be disconnected so we do a manual tree traversal
- return findElements(this, index, result, p, ns, localName);
- } else if (target instanceof OriginalElement) {
- list = originalElementGetElementsByTagNameNS.call(target, ns, localName);
- } else if (target instanceof OriginalDocument) {
- list = originalDocumentGetElementsByTagNameNS.call(target, ns, localName);
- } else {
- // When we get a ShadowRoot the logical tree is going to be disconnected
- // so we do a manual tree traversal
- return findElements(this, index, result, p, ns, localName);
- }
-
- return filterNodeList(list, index, result, false);
- }
-
- var GetElementsByInterface = {
- getElementsByTagName: function(localName) {
- var result = new HTMLCollection();
- var match = localName === '*' ? matchesEveryThing : matchesTagName;
-
- result.length = getElementsByTagNameFiltered.call(this,
- match,
- 0,
- result,
- localName,
- localName.toLowerCase());
-
- return result;
- },
-
- getElementsByClassName: function(className) {
- // TODO(arv): Check className?
- return this.querySelectorAll('.' + className);
- },
-
- getElementsByTagNameNS: function(ns, localName) {
- var result = new HTMLCollection();
- var match = null;
-
- if (ns === '*') {
- match = localName === '*' ? matchesEveryThing : matchesLocalNameOnly;
- } else {
- match = localName === '*' ? matchesNameSpace : matchesLocalNameNS;
- }
-
- result.length = getElementsByTagNameNSFiltered.call(this,
- match,
- 0,
- result,
- ns || null,
- localName);
-
- return result;
- }
- };
-
- scope.GetElementsByInterface = GetElementsByInterface;
- scope.SelectorsInterface = SelectorsInterface;
- scope.MatchesInterface = MatchesInterface;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers.js b/src/ShadowDOM/wrappers.js
deleted file mode 100644
index e073836..0000000
--- a/src/ShadowDOM/wrappers.js
+++ /dev/null
@@ -1,457 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-window.ShadowDOMPolyfill = {};
-
-(function(scope) {
- 'use strict';
-
- var constructorTable = new WeakMap();
- var nativePrototypeTable = new WeakMap();
- var wrappers = Object.create(null);
-
- function detectEval() {
- // Don't test for eval if we're running in a Chrome App environment.
- // We check for APIs set that only exist in a Chrome App context.
- if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
- return false;
- }
-
- // Firefox OS Apps do not allow eval. This feature detection is very hacky
- // but even if some other platform adds support for this function this code
- // will continue to work.
- if (navigator.getDeviceStorage) {
- return false;
- }
-
- try {
- var f = new Function('return true;');
- return f();
- } catch (ex) {
- return false;
- }
- }
-
- var hasEval = detectEval();
-
- function assert(b) {
- if (!b)
- throw new Error('Assertion failed');
- };
-
- var defineProperty = Object.defineProperty;
- var getOwnPropertyNames = Object.getOwnPropertyNames;
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
-
- function mixin(to, from) {
- var names = getOwnPropertyNames(from);
- for (var i = 0; i < names.length; i++) {
- var name = names[i];
- defineProperty(to, name, getOwnPropertyDescriptor(from, name));
- }
- return to;
- };
-
- function mixinStatics(to, from) {
- var names = getOwnPropertyNames(from);
- for (var i = 0; i < names.length; i++) {
- var name = names[i];
- switch (name) {
- case 'arguments':
- case 'caller':
- case 'length':
- case 'name':
- case 'prototype':
- case 'toString':
- continue;
- }
- defineProperty(to, name, getOwnPropertyDescriptor(from, name));
- }
- return to;
- };
-
- function oneOf(object, propertyNames) {
- for (var i = 0; i < propertyNames.length; i++) {
- if (propertyNames[i] in object)
- return propertyNames[i];
- }
- }
-
- var nonEnumerableDataDescriptor = {
- value: undefined,
- configurable: true,
- enumerable: false,
- writable: true
- };
-
- function defineNonEnumerableDataProperty(object, name, value) {
- nonEnumerableDataDescriptor.value = value;
- defineProperty(object, name, nonEnumerableDataDescriptor);
- }
-
- // Mozilla's old DOM bindings are bretty busted:
- // https://bugzilla.mozilla.org/show_bug.cgi?id=855844
- // Make sure they are create before we start modifying things.
- getOwnPropertyNames(window);
-
- function getWrapperConstructor(node, opt_instance) {
- var nativePrototype = node.__proto__ || Object.getPrototypeOf(node);
- if (isFirefox) {
- // HTMLEmbedElements will sometimes be [NS Object wrapper class]
- // which throws an error when getOwnPropertyNames is called on it.
- // Mozilla handily includes a second HTMLEmbedElementPrototype in
- // the chain, so we use that one if available.
- try {
- getOwnPropertyNames(nativePrototype);
- } catch (error) {
- nativePrototype = nativePrototype.__proto__;
- }
- }
- var wrapperConstructor = constructorTable.get(nativePrototype);
- if (wrapperConstructor)
- return wrapperConstructor;
-
- var parentWrapperConstructor = getWrapperConstructor(nativePrototype);
-
- var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor);
- registerInternal(nativePrototype, GeneratedWrapper, opt_instance);
-
- return GeneratedWrapper;
- }
-
- function addForwardingProperties(nativePrototype, wrapperPrototype) {
- installProperty(nativePrototype, wrapperPrototype, true);
- }
-
- function registerInstanceProperties(wrapperPrototype, instanceObject) {
- installProperty(instanceObject, wrapperPrototype, false);
- }
-
- var isFirefox = /Firefox/.test(navigator.userAgent);
-
- // This is used as a fallback when getting the descriptor fails in
- // installProperty.
- var dummyDescriptor = {
- get: function() {},
- set: function(v) {},
- configurable: true,
- enumerable: true
- };
-
- function isEventHandlerName(name) {
- return /^on[a-z]+$/.test(name);
- }
-
- function isIdentifierName(name) {
- return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(name);
- }
-
- // The name of the implementation property is intentionally hard to
- // remember. Unfortunately, browsers are slower doing obj[expr] than
- // obj.foo so we resort to repeat this ugly name. This ugly name is never
- // used outside of this file though.
-
- function getGetter(name) {
- return hasEval && isIdentifierName(name) ?
- new Function('return this.__impl4cf1e782hg__.' + name) :
- function() { return this.__impl4cf1e782hg__[name]; };
- }
-
- function getSetter(name) {
- return hasEval && isIdentifierName(name) ?
- new Function('v', 'this.__impl4cf1e782hg__.' + name + ' = v') :
- function(v) { this.__impl4cf1e782hg__[name] = v; };
- }
-
- function getMethod(name) {
- return hasEval && isIdentifierName(name) ?
- new Function('return this.__impl4cf1e782hg__.' + name +
- '.apply(this.__impl4cf1e782hg__, arguments)') :
- function() {
- return this.__impl4cf1e782hg__[name].apply(
- this.__impl4cf1e782hg__, arguments);
- };
- }
-
- function getDescriptor(source, name) {
- try {
- return Object.getOwnPropertyDescriptor(source, name);
- } catch (ex) {
- // JSC and V8 both use data properties instead of accessors which can
- // cause getting the property desciptor to throw an exception.
- // https://bugs.webkit.org/show_bug.cgi?id=49739
- return dummyDescriptor;
- }
- }
-
- // Safari 8 exposes WebIDL attributes as an invalid accessor property. Its
- // descriptor has {get: undefined, set: undefined}. We therefore ignore the
- // shape of the descriptor and make all properties read-write.
- // https://bugs.webkit.org/show_bug.cgi?id=49739
- var isBrokenSafari = function() {
- var descr = Object.getOwnPropertyDescriptor(Node.prototype, 'nodeType');
- return descr && !descr.get && !descr.set;
- }();
-
- function installProperty(source, target, allowMethod, opt_blacklist) {
- var names = getOwnPropertyNames(source);
- for (var i = 0; i < names.length; i++) {
- var name = names[i];
- if (name === 'polymerBlackList_')
- continue;
-
- if (name in target)
- continue;
-
- if (source.polymerBlackList_ && source.polymerBlackList_[name])
- continue;
-
- if (isFirefox) {
- // Tickle Firefox's old bindings.
- source.__lookupGetter__(name);
- }
- var descriptor = getDescriptor(source, name);
- var getter, setter;
- if(typeof descriptor.value === 'function') {
- if (allowMethod) {
- target[name] = getMethod(name);
- }
- continue;
- }
-
- var isEvent = isEventHandlerName(name);
- if (isEvent)
- getter = scope.getEventHandlerGetter(name);
- else
- getter = getGetter(name);
-
- if (descriptor.writable || descriptor.set || isBrokenSafari) {
- if (isEvent)
- setter = scope.getEventHandlerSetter(name);
- else
- setter = getSetter(name);
- }
-
- // make all descriptors configurable on broken safari
- var configurable = isBrokenSafari || descriptor.configurable;
-
- defineProperty(target, name, {
- get: getter,
- set: setter,
- configurable: configurable,
- enumerable: descriptor.enumerable
- });
- }
- }
-
- /**
- * @param {Function} nativeConstructor
- * @param {Function} wrapperConstructor
- * @param {Object=} opt_instance If present, this is used to extract
- * properties from an instance object.
- */
- function register(nativeConstructor, wrapperConstructor, opt_instance) {
- if (nativeConstructor == null) {
- return;
- }
- var nativePrototype = nativeConstructor.prototype;
- registerInternal(nativePrototype, wrapperConstructor, opt_instance);
- mixinStatics(wrapperConstructor, nativeConstructor);
- }
-
- function registerInternal(nativePrototype, wrapperConstructor, opt_instance) {
- var wrapperPrototype = wrapperConstructor.prototype;
- assert(constructorTable.get(nativePrototype) === undefined);
-
- constructorTable.set(nativePrototype, wrapperConstructor);
- nativePrototypeTable.set(wrapperPrototype, nativePrototype);
-
- addForwardingProperties(nativePrototype, wrapperPrototype);
- if (opt_instance)
- registerInstanceProperties(wrapperPrototype, opt_instance);
-
- defineNonEnumerableDataProperty(
- wrapperPrototype, 'constructor', wrapperConstructor);
- // Set it again. Some VMs optimizes objects that are used as prototypes.
- wrapperConstructor.prototype = wrapperPrototype;
- }
-
- function isWrapperFor(wrapperConstructor, nativeConstructor) {
- return constructorTable.get(nativeConstructor.prototype) ===
- wrapperConstructor;
- }
-
- /**
- * Creates a generic wrapper constructor based on |object| and its
- * constructor.
- * @param {Node} object
- * @return {Function} The generated constructor.
- */
- function registerObject(object) {
- var nativePrototype = Object.getPrototypeOf(object);
-
- var superWrapperConstructor = getWrapperConstructor(nativePrototype);
- var GeneratedWrapper = createWrapperConstructor(superWrapperConstructor);
- registerInternal(nativePrototype, GeneratedWrapper, object);
-
- return GeneratedWrapper;
- }
-
- function createWrapperConstructor(superWrapperConstructor) {
- function GeneratedWrapper(node) {
- superWrapperConstructor.call(this, node);
- }
- var p = Object.create(superWrapperConstructor.prototype);
- p.constructor = GeneratedWrapper;
- GeneratedWrapper.prototype = p;
-
- return GeneratedWrapper;
- }
-
- function isWrapper(object) {
- return object && object.__impl4cf1e782hg__;
- }
-
- function isNative(object) {
- return !isWrapper(object);
- }
-
- /**
- * Wraps a node in a WrapperNode. If there already exists a wrapper for the
- * |node| that wrapper is returned instead.
- * @param {Node} node
- * @return {WrapperNode}
- */
- function wrap(impl) {
- if (impl === null)
- return null;
-
- assert(isNative(impl));
- var wrapper = impl.__wrapper8e3dd93a60__;
- if (wrapper != null) {
- return wrapper;
- }
-
- return impl.__wrapper8e3dd93a60__ =
- new (getWrapperConstructor(impl, impl))(impl);
- }
-
- /**
- * Unwraps a wrapper and returns the node it is wrapping.
- * @param {WrapperNode} wrapper
- * @return {Node}
- */
- function unwrap(wrapper) {
- if (wrapper === null)
- return null;
- assert(isWrapper(wrapper));
- return wrapper.__impl4cf1e782hg__;
- }
-
- function unsafeUnwrap(wrapper) {
- return wrapper.__impl4cf1e782hg__;
- }
-
- function setWrapper(impl, wrapper) {
- wrapper.__impl4cf1e782hg__ = impl;
- impl.__wrapper8e3dd93a60__ = wrapper;
- }
-
- /**
- * Unwraps object if it is a wrapper.
- * @param {Object} object
- * @return {Object} The native implementation object.
- */
- function unwrapIfNeeded(object) {
- return object && isWrapper(object) ? unwrap(object) : object;
- }
-
- /**
- * Wraps object if it is not a wrapper.
- * @param {Object} object
- * @return {Object} The wrapper for object.
- */
- function wrapIfNeeded(object) {
- return object && !isWrapper(object) ? wrap(object) : object;
- }
-
- /**
- * Overrides the current wrapper (if any) for node.
- * @param {Node} node
- * @param {WrapperNode=} wrapper If left out the wrapper will be created as
- * needed next time someone wraps the node.
- */
- function rewrap(node, wrapper) {
- if (wrapper === null)
- return;
- assert(isNative(node));
- assert(wrapper === undefined || isWrapper(wrapper));
- node.__wrapper8e3dd93a60__ = wrapper;
- }
-
- var getterDescriptor = {
- get: undefined,
- configurable: true,
- enumerable: true
- };
-
- function defineGetter(constructor, name, getter) {
- getterDescriptor.get = getter;
- defineProperty(constructor.prototype, name, getterDescriptor);
- }
-
- function defineWrapGetter(constructor, name) {
- defineGetter(constructor, name, function() {
- return wrap(this.__impl4cf1e782hg__[name]);
- });
- }
-
- /**
- * Forwards existing methods on the native object to the wrapper methods.
- * This does not wrap any of the arguments or the return value since the
- * wrapper implementation already takes care of that.
- * @param {Array.} constructors
- * @parem {Array.} names
- */
- function forwardMethodsToWrapper(constructors, names) {
- constructors.forEach(function(constructor) {
- names.forEach(function(name) {
- constructor.prototype[name] = function() {
- var w = wrapIfNeeded(this);
- return w[name].apply(w, arguments);
- };
- });
- });
- }
-
- scope.addForwardingProperties = addForwardingProperties;
- scope.assert = assert;
- scope.constructorTable = constructorTable;
- scope.defineGetter = defineGetter;
- scope.defineWrapGetter = defineWrapGetter;
- scope.forwardMethodsToWrapper = forwardMethodsToWrapper;
- scope.isIdentifierName = isIdentifierName;
- scope.isWrapper = isWrapper;
- scope.isWrapperFor = isWrapperFor;
- scope.mixin = mixin;
- scope.nativePrototypeTable = nativePrototypeTable;
- scope.oneOf = oneOf;
- scope.registerObject = registerObject;
- scope.registerWrapper = register;
- scope.rewrap = rewrap;
- scope.setWrapper = setWrapper;
- scope.unsafeUnwrap = unsafeUnwrap;
- scope.unwrap = unwrap;
- scope.unwrapIfNeeded = unwrapIfNeeded;
- scope.wrap = wrap;
- scope.wrapIfNeeded = wrapIfNeeded;
- scope.wrappers = wrappers;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/CanvasRenderingContext2D.js b/src/ShadowDOM/wrappers/CanvasRenderingContext2D.js
deleted file mode 100644
index 44ac212..0000000
--- a/src/ShadowDOM/wrappers/CanvasRenderingContext2D.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
-
- var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
-
- function CanvasRenderingContext2D(impl) {
- setWrapper(impl, this);
- }
-
- mixin(CanvasRenderingContext2D.prototype, {
- get canvas() {
- return wrap(unsafeUnwrap(this).canvas);
- },
-
- drawImage: function() {
- arguments[0] = unwrapIfNeeded(arguments[0]);
- unsafeUnwrap(this).drawImage.apply(unsafeUnwrap(this), arguments);
- },
-
- createPattern: function() {
- arguments[0] = unwrap(arguments[0]);
- return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), arguments);
- }
- });
-
- registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D,
- document.createElement('canvas').getContext('2d'));
-
- scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/CharacterData.js b/src/ShadowDOM/wrappers/CharacterData.js
deleted file mode 100644
index 95e1986..0000000
--- a/src/ShadowDOM/wrappers/CharacterData.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var ChildNodeInterface = scope.ChildNodeInterface;
- var Node = scope.wrappers.Node;
- var enqueueMutation = scope.enqueueMutation;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
-
- var OriginalCharacterData = window.CharacterData;
-
- function CharacterData(node) {
- Node.call(this, node);
- }
- CharacterData.prototype = Object.create(Node.prototype);
- mixin(CharacterData.prototype, {
- get nodeValue() {
- return this.data;
- },
- set nodeValue(data) {
- this.data = data;
- },
- get textContent() {
- return this.data;
- },
- set textContent(value) {
- this.data = value;
- },
- get data() {
- return unsafeUnwrap(this).data;
- },
- set data(value) {
- var oldValue = unsafeUnwrap(this).data;
- enqueueMutation(this, 'characterData', {
- oldValue: oldValue
- });
- unsafeUnwrap(this).data = value;
- }
- });
-
- mixin(CharacterData.prototype, ChildNodeInterface);
-
- registerWrapper(OriginalCharacterData, CharacterData,
- document.createTextNode(''));
-
- scope.wrappers.CharacterData = CharacterData;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/DOMTokenList.js b/src/ShadowDOM/wrappers/DOMTokenList.js
deleted file mode 100644
index 5345134..0000000
--- a/src/ShadowDOM/wrappers/DOMTokenList.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-// NOTE: Set the 'ownerElement_' property on a DOMTokenList to make invalidation
-// happen. This is pretty hacky but we only have to do it in one place
-// (Element.js) currently so it seems like the least bad option.
-(function(scope) {
- 'use strict';
-
- if (!window.DOMTokenList) {
- console.warn('Missing DOMTokenList prototype, please include a ' +
- 'compatible classList polyfill such as http://goo.gl/uTcepH.');
- return;
- }
-
- var unsafeUnwrap = scope.unsafeUnwrap;
- var enqueueMutation = scope.enqueueMutation;
-
- function getClass (el) {
- return unsafeUnwrap(el).getAttribute('class');
- }
-
- function enqueueClassAttributeChange(el, oldValue) {
- enqueueMutation(el, 'attributes', {
- name: 'class',
- namespace: null,
- oldValue: oldValue
- });
- }
-
- function invalidateClass(el) {
- scope.invalidateRendererBasedOnAttribute(el, 'class');
- }
-
- function changeClass(tokenList, method, args) {
- var ownerElement = tokenList.ownerElement_;
- if (ownerElement == null) {
- return method.apply(tokenList, args);
- }
-
- var oldValue = getClass(ownerElement);
- var retv = method.apply(tokenList, args);
- if (getClass(ownerElement) !== oldValue) {
- enqueueClassAttributeChange(ownerElement, oldValue);
- invalidateClass(ownerElement);
- }
-
- return retv;
- }
-
- var oldAdd = DOMTokenList.prototype.add;
- DOMTokenList.prototype.add = function() {
- changeClass(this, oldAdd, arguments);
- };
-
- var oldRemove = DOMTokenList.prototype.remove;
- DOMTokenList.prototype.remove = function() {
- changeClass(this, oldRemove, arguments);
- };
-
- var oldToggle = DOMTokenList.prototype.toggle;
- DOMTokenList.prototype.toggle = function() {
- return changeClass(this, oldToggle, arguments);
- };
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/DataTransfer.js b/src/ShadowDOM/wrappers/DataTransfer.js
deleted file mode 100644
index 528c14a..0000000
--- a/src/ShadowDOM/wrappers/DataTransfer.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var unwrap = scope.unwrap;
-
- // DataTransfer (Clipboard in old Blink/WebKit) has a single method that
- // requires wrapping. Since it is only a method we do not need a real wrapper,
- // we can just override the method.
-
- var OriginalDataTransfer = window.DataTransfer || window.Clipboard;
- var OriginalDataTransferSetDragImage =
- OriginalDataTransfer.prototype.setDragImage;
-
- if (OriginalDataTransferSetDragImage) {
- OriginalDataTransfer.prototype.setDragImage = function(image, x, y) {
- OriginalDataTransferSetDragImage.call(this, unwrap(image), x, y);
- };
- }
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Document.js b/src/ShadowDOM/wrappers/Document.js
deleted file mode 100644
index 4ceffaa..0000000
--- a/src/ShadowDOM/wrappers/Document.js
+++ /dev/null
@@ -1,408 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var GetElementsByInterface = scope.GetElementsByInterface;
- var Node = scope.wrappers.Node;
- var ParentNodeInterface = scope.ParentNodeInterface;
- var NonElementParentNodeInterface = scope.NonElementParentNodeInterface;
- var Selection = scope.wrappers.Selection;
- var SelectorsInterface = scope.SelectorsInterface;
- var ShadowRoot = scope.wrappers.ShadowRoot;
- var TreeScope = scope.TreeScope;
- var cloneNode = scope.cloneNode;
- var defineGetter = scope.defineGetter;
- var defineWrapGetter = scope.defineWrapGetter;
- var elementFromPoint = scope.elementFromPoint;
- var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
- var matchesNames = scope.matchesNames;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var renderAllPending = scope.renderAllPending;
- var rewrap = scope.rewrap;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
- var wrapEventTargetMethods = scope.wrapEventTargetMethods;
- var wrapNodeList = scope.wrapNodeList;
-
- var implementationTable = new WeakMap();
-
- function Document(node) {
- Node.call(this, node);
- this.treeScope_ = new TreeScope(this, null);
- }
- Document.prototype = Object.create(Node.prototype);
-
- defineWrapGetter(Document, 'documentElement');
-
- // Conceptually both body and head can be in a shadow but supporting that seems
- // overkill at this point.
- defineWrapGetter(Document, 'body');
- defineWrapGetter(Document, 'head');
-
- defineGetter(Document, 'activeElement', function() {
- var unwrappedActiveElement = unwrap(this).activeElement;
- if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
-
- var activeElement = wrap(unwrappedActiveElement);
-
- // Loop while activeElement is not a shallow child of this document.
- while (!this.contains(activeElement)) {
- // Iterate until we hit activeElement's containing ShadowRoot (which
- // isn't this one) or document.
- while (activeElement.parentNode) {
- activeElement = activeElement.parentNode;
- }
-
- // If we've reached a ShadowRoot, move to its host.
- if (activeElement.host) {
- activeElement = activeElement.host;
- // Otherwise, we've reached a different document - this document is
- // not an ancestor of the active element.
- } else {
- return null;
- }
- }
-
- return activeElement;
- });
-
- // document cannot be overridden so we override a bunch of its methods
- // directly on the instance.
-
- function wrapMethod(name) {
- var original = document[name];
- Document.prototype[name] = function() {
- return wrap(original.apply(unsafeUnwrap(this), arguments));
- };
- }
-
- [
- 'createComment',
- 'createDocumentFragment',
- 'createElement',
- 'createElementNS',
- 'createEvent',
- 'createEventNS',
- 'createRange',
- 'createTextNode',
- ].forEach(wrapMethod);
-
- var originalAdoptNode = document.adoptNode;
-
- function adoptNodeNoRemove(node, doc) {
- originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node));
- adoptSubtree(node, doc);
- }
-
- function adoptSubtree(node, doc) {
- if (node.shadowRoot)
- doc.adoptNode(node.shadowRoot);
- if (node instanceof ShadowRoot)
- adoptOlderShadowRoots(node, doc);
- for (var child = node.firstChild; child; child = child.nextSibling) {
- adoptSubtree(child, doc);
- }
- }
-
- function adoptOlderShadowRoots(shadowRoot, doc) {
- var oldShadowRoot = shadowRoot.olderShadowRoot;
- if (oldShadowRoot)
- doc.adoptNode(oldShadowRoot);
- }
-
- var originalGetSelection = document.getSelection;
-
- mixin(Document.prototype, {
- adoptNode: function(node) {
- if (node.parentNode)
- node.parentNode.removeChild(node);
- adoptNodeNoRemove(node, this);
- return node;
- },
- elementFromPoint: function(x, y) {
- return elementFromPoint(this, this, x, y);
- },
- importNode: function(node, deep) {
- return cloneNode(node, deep, unsafeUnwrap(this));
- },
- getSelection: function() {
- renderAllPending();
- return new Selection(originalGetSelection.call(unwrap(this)));
- },
- getElementsByName: function(name) {
- return SelectorsInterface.querySelectorAll.call(this,
- '[name=' + JSON.stringify(String(name)) + ']');
- }
- });
-
- var originalCreateTreeWalker = document.createTreeWalker;
- var TreeWalkerWrapper = scope.wrappers.TreeWalker;
- Document.prototype.createTreeWalker = function(root, whatToShow,
- filter, expandEntityReferences) {
-
- var newFilter = null; // IE does not like undefined.
-
- // Support filter as a function or object with function defined as
- // acceptNode. IE supports filter as a function only.
- // Chrome and FF support both formats.
- if (filter) {
- if (filter.acceptNode && typeof filter.acceptNode === 'function') {
- newFilter = {
- acceptNode: function(node) {
- return filter.acceptNode(wrap(node));
- }
- };
- } else if (typeof filter === 'function') {
- newFilter = function(node) {
- return filter(wrap(node));
- }
- }
- }
-
- return new TreeWalkerWrapper(
- originalCreateTreeWalker.call(unwrap(this), unwrap(root),
- whatToShow, newFilter, expandEntityReferences));
- };
-
- if (document.registerElement) {
- var originalRegisterElement = document.registerElement;
- Document.prototype.registerElement = function(tagName, object) {
- var prototype, extendsOption;
- if (object !== undefined) {
- prototype = object.prototype;
- extendsOption = object.extends;
- }
-
- if (!prototype)
- prototype = Object.create(HTMLElement.prototype);
-
- // If we already used the object as a prototype for another custom
- // element.
- if (scope.nativePrototypeTable.get(prototype)) {
- // TODO(arv): DOMException
- throw new Error('NotSupportedError');
- }
-
- // Find first object on the prototype chain that already have a native
- // prototype. Keep track of all the objects before that so we can create
- // a similar structure for the native case.
- var proto = Object.getPrototypeOf(prototype);
- var nativePrototype;
- var prototypes = [];
- while (proto) {
- nativePrototype = scope.nativePrototypeTable.get(proto);
- if (nativePrototype)
- break;
- prototypes.push(proto);
- proto = Object.getPrototypeOf(proto);
- }
-
- if (!nativePrototype) {
- // TODO(arv): DOMException
- throw new Error('NotSupportedError');
- }
-
- // This works by creating a new prototype object that is empty, but has
- // the native prototype as its proto. The original prototype object
- // passed into register is used as the wrapper prototype.
-
- var newPrototype = Object.create(nativePrototype);
- for (var i = prototypes.length - 1; i >= 0; i--) {
- newPrototype = Object.create(newPrototype);
- }
-
- // Add callbacks if present.
- // Names are taken from:
- // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/bindings/v8/CustomElementConstructorBuilder.cpp&sq=package:chromium&type=cs&l=156
- // and not from the spec since the spec is out of date.
- [
- 'createdCallback',
- 'attachedCallback',
- 'detachedCallback',
- 'attributeChangedCallback',
- ].forEach(function(name) {
- var f = prototype[name];
- if (!f)
- return;
- newPrototype[name] = function() {
- // if this element has been wrapped prior to registration,
- // the wrapper is stale; in this case rewrap
- if (!(wrap(this) instanceof CustomElementConstructor)) {
- rewrap(this);
- }
- f.apply(wrap(this), arguments);
- };
- });
-
- var p = {prototype: newPrototype};
- if (extendsOption)
- p.extends = extendsOption;
-
- function CustomElementConstructor(node) {
- if (!node) {
- if (extendsOption) {
- return document.createElement(extendsOption, tagName);
- } else {
- return document.createElement(tagName);
- }
- }
- setWrapper(node, this);
- }
- CustomElementConstructor.prototype = prototype;
- CustomElementConstructor.prototype.constructor = CustomElementConstructor;
-
- scope.constructorTable.set(newPrototype, CustomElementConstructor);
- scope.nativePrototypeTable.set(prototype, newPrototype);
-
- // registration is synchronous so do it last
- var nativeConstructor = originalRegisterElement.call(unwrap(this),
- tagName, p);
- return CustomElementConstructor;
- };
-
- forwardMethodsToWrapper([
- window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument
- ], [
- 'registerElement',
- ]);
- }
-
- // We also override some of the methods on document.body and document.head
- // for convenience.
- forwardMethodsToWrapper([
- window.HTMLBodyElement,
- window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument
- window.HTMLHeadElement,
- window.HTMLHtmlElement,
- ], [
- 'appendChild',
- 'compareDocumentPosition',
- 'contains',
- 'getElementsByClassName',
- 'getElementsByTagName',
- 'getElementsByTagNameNS',
- 'insertBefore',
- 'querySelector',
- 'querySelectorAll',
- 'removeChild',
- 'replaceChild',
- ]);
-
- forwardMethodsToWrapper([
- window.HTMLBodyElement,
- window.HTMLHeadElement,
- window.HTMLHtmlElement,
- ], matchesNames);
-
- forwardMethodsToWrapper([
- window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument
- ], [
- 'adoptNode',
- 'importNode',
- 'contains',
- 'createComment',
- 'createDocumentFragment',
- 'createElement',
- 'createElementNS',
- 'createEvent',
- 'createEventNS',
- 'createRange',
- 'createTextNode',
- 'createTreeWalker',
- 'elementFromPoint',
- 'getElementById',
- 'getElementsByName',
- 'getSelection',
- ]);
-
- mixin(Document.prototype, GetElementsByInterface);
- mixin(Document.prototype, ParentNodeInterface);
- mixin(Document.prototype, SelectorsInterface);
- mixin(Document.prototype, NonElementParentNodeInterface);
-
- mixin(Document.prototype, {
- get implementation() {
- var implementation = implementationTable.get(this);
- if (implementation)
- return implementation;
- implementation =
- new DOMImplementation(unwrap(this).implementation);
- implementationTable.set(this, implementation);
- return implementation;
- },
-
- get defaultView() {
- return wrap(unwrap(this).defaultView);
- }
- });
-
- registerWrapper(window.Document, Document,
- document.implementation.createHTMLDocument(''));
-
- // Both WebKit and Gecko uses HTMLDocument for document. HTML5/DOM only has
- // one Document interface and IE implements the standard correctly.
- if (window.HTMLDocument)
- registerWrapper(window.HTMLDocument, Document);
-
- wrapEventTargetMethods([
- window.HTMLBodyElement,
- window.HTMLDocument || window.Document, // Gecko adds these to HTMLDocument
- window.HTMLHeadElement,
- ]);
-
- function DOMImplementation(impl) {
- setWrapper(impl, this);
- }
-
- var originalCreateDocument = document.implementation.createDocument;
- DOMImplementation.prototype.createDocument = function() {
- arguments[2] = unwrap(arguments[2]);
- return wrap(originalCreateDocument.apply(unsafeUnwrap(this), arguments));
- };
-
- function wrapImplMethod(constructor, name) {
- var original = document.implementation[name];
- constructor.prototype[name] = function() {
- return wrap(original.apply(unsafeUnwrap(this), arguments));
- };
- }
-
- function forwardImplMethod(constructor, name) {
- var original = document.implementation[name];
- constructor.prototype[name] = function() {
- return original.apply(unsafeUnwrap(this), arguments);
- };
- }
-
- wrapImplMethod(DOMImplementation, 'createDocumentType');
- wrapImplMethod(DOMImplementation, 'createHTMLDocument');
- forwardImplMethod(DOMImplementation, 'hasFeature');
-
- registerWrapper(window.DOMImplementation, DOMImplementation);
-
- forwardMethodsToWrapper([
- window.DOMImplementation,
- ], [
- 'createDocument',
- 'createDocumentType',
- 'createHTMLDocument',
- 'hasFeature',
- ]);
-
- scope.adoptNodeNoRemove = adoptNodeNoRemove;
- scope.wrappers.DOMImplementation = DOMImplementation;
- scope.wrappers.Document = Document;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Element.js b/src/ShadowDOM/wrappers/Element.js
deleted file mode 100644
index 0fc646c..0000000
--- a/src/ShadowDOM/wrappers/Element.js
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var ChildNodeInterface = scope.ChildNodeInterface;
- var GetElementsByInterface = scope.GetElementsByInterface;
- var Node = scope.wrappers.Node;
- var ParentNodeInterface = scope.ParentNodeInterface;
- var SelectorsInterface = scope.SelectorsInterface;
- var MatchesInterface = scope.MatchesInterface;
- var addWrapNodeListMethod = scope.addWrapNodeListMethod;
- var enqueueMutation = scope.enqueueMutation;
- var mixin = scope.mixin;
- var oneOf = scope.oneOf;
- var registerWrapper = scope.registerWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrappers = scope.wrappers;
-
- var OriginalElement = window.Element;
-
- var matchesNames = [
- 'matches', // needs to come first.
- 'mozMatchesSelector',
- 'msMatchesSelector',
- 'webkitMatchesSelector',
- ].filter(function(name) {
- return OriginalElement.prototype[name];
- });
-
- var matchesName = matchesNames[0];
-
- var originalMatches = OriginalElement.prototype[matchesName];
-
- function invalidateRendererBasedOnAttribute(element, name) {
- // Only invalidate if parent node is a shadow host.
- var p = element.parentNode;
- if (!p || !p.shadowRoot)
- return;
-
- var renderer = scope.getRendererForHost(p);
- if (renderer.dependsOnAttribute(name))
- renderer.invalidate();
- }
-
- function enqueAttributeChange(element, name, oldValue) {
- // This is not fully spec compliant. We should use localName (which might
- // have a different case than name) and the namespace (which requires us
- // to get the Attr object).
- enqueueMutation(element, 'attributes', {
- name: name,
- namespace: null,
- oldValue: oldValue
- });
- }
-
- var classListTable = new WeakMap();
-
- function Element(node) {
- Node.call(this, node);
- }
- Element.prototype = Object.create(Node.prototype);
- mixin(Element.prototype, {
- createShadowRoot: function() {
- var newShadowRoot = new wrappers.ShadowRoot(this);
- unsafeUnwrap(this).polymerShadowRoot_ = newShadowRoot;
-
- var renderer = scope.getRendererForHost(this);
- renderer.invalidate();
-
- return newShadowRoot;
- },
-
- get shadowRoot() {
- return unsafeUnwrap(this).polymerShadowRoot_ || null;
- },
-
- // getDestinationInsertionPoints added in ShadowRenderer.js
-
- setAttribute: function(name, value) {
- var oldValue = unsafeUnwrap(this).getAttribute(name);
- unsafeUnwrap(this).setAttribute(name, value);
- enqueAttributeChange(this, name, oldValue);
- invalidateRendererBasedOnAttribute(this, name);
- },
-
- removeAttribute: function(name) {
- var oldValue = unsafeUnwrap(this).getAttribute(name);
- unsafeUnwrap(this).removeAttribute(name);
- enqueAttributeChange(this, name, oldValue);
- invalidateRendererBasedOnAttribute(this, name);
- },
-
- get classList() {
- var list = classListTable.get(this);
- if (!list) {
- list = unsafeUnwrap(this).classList;
- if (!list) return;
- list.ownerElement_ = this;
- classListTable.set(this, list);
- }
- return list;
- },
-
- get className() {
- return unsafeUnwrap(this).className;
- },
-
- set className(v) {
- this.setAttribute('class', v);
- },
-
- get id() {
- return unsafeUnwrap(this).id;
- },
-
- set id(v) {
- this.setAttribute('id', v);
- }
- });
-
- matchesNames.forEach(function(name) {
- if (name !== 'matches') {
- Element.prototype[name] = function(selector) {
- return this.matches(selector);
- };
- }
- });
-
- if (OriginalElement.prototype.webkitCreateShadowRoot) {
- Element.prototype.webkitCreateShadowRoot =
- Element.prototype.createShadowRoot;
- }
-
- mixin(Element.prototype, ChildNodeInterface);
- mixin(Element.prototype, GetElementsByInterface);
- mixin(Element.prototype, ParentNodeInterface);
- mixin(Element.prototype, SelectorsInterface);
- mixin(Element.prototype, MatchesInterface);
-
- registerWrapper(OriginalElement, Element,
- document.createElementNS(null, 'x'));
-
- scope.invalidateRendererBasedOnAttribute = invalidateRendererBasedOnAttribute;
- scope.matchesNames = matchesNames;
- scope.originalMatches = originalMatches;
- scope.wrappers.Element = Element;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/FormData.js b/src/ShadowDOM/wrappers/FormData.js
deleted file mode 100644
index 57cb27b..0000000
--- a/src/ShadowDOM/wrappers/FormData.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unwrap = scope.unwrap;
-
- var OriginalFormData = window.FormData;
- if (!OriginalFormData) return;
-
- function FormData(formElement) {
- var impl;
- if (formElement instanceof OriginalFormData) {
- impl = formElement;
- } else {
- impl = new OriginalFormData(formElement && unwrap(formElement));
- }
- setWrapper(impl, this);
- }
-
- registerWrapper(OriginalFormData, FormData, new OriginalFormData());
-
- scope.wrappers.FormData = FormData;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLAudioElement.js b/src/ShadowDOM/wrappers/HTMLAudioElement.js
deleted file mode 100644
index 71e668a..0000000
--- a/src/ShadowDOM/wrappers/HTMLAudioElement.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLMediaElement = scope.wrappers.HTMLMediaElement;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var rewrap = scope.rewrap;
-
- var OriginalHTMLAudioElement = window.HTMLAudioElement;
-
- if (!OriginalHTMLAudioElement) return;
-
- function HTMLAudioElement(node) {
- HTMLMediaElement.call(this, node);
- }
- HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype);
-
- registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement,
- document.createElement('audio'));
-
- function Audio(src) {
- if (!(this instanceof Audio)) {
- throw new TypeError(
- 'DOM object constructor cannot be called as a function.');
- }
-
- var node = unwrap(document.createElement('audio'));
- HTMLMediaElement.call(this, node);
- rewrap(node, this);
-
- node.setAttribute('preload', 'auto');
- if (src !== undefined)
- node.setAttribute('src', src);
- }
-
- Audio.prototype = HTMLAudioElement.prototype;
-
- scope.wrappers.HTMLAudioElement = HTMLAudioElement;
- scope.wrappers.Audio = Audio;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLCanvasElement.js b/src/ShadowDOM/wrappers/HTMLCanvasElement.js
deleted file mode 100644
index 71b962d..0000000
--- a/src/ShadowDOM/wrappers/HTMLCanvasElement.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
-
- var OriginalHTMLCanvasElement = window.HTMLCanvasElement;
-
- function HTMLCanvasElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype);
-
- mixin(HTMLCanvasElement.prototype, {
- getContext: function() {
- var context = unsafeUnwrap(this).getContext.apply(unsafeUnwrap(this), arguments);
- return context && wrap(context);
- }
- });
-
- registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement,
- document.createElement('canvas'));
-
- scope.wrappers.HTMLCanvasElement = HTMLCanvasElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLCollection.js b/src/ShadowDOM/wrappers/HTMLCollection.js
deleted file mode 100644
index 64cd1bb..0000000
--- a/src/ShadowDOM/wrappers/HTMLCollection.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- // TODO(arv): Implement.
-
- scope.wrapHTMLCollection = scope.wrapNodeList;
- scope.wrappers.HTMLCollection = scope.wrappers.NodeList;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLContentElement.js b/src/ShadowDOM/wrappers/HTMLContentElement.js
deleted file mode 100644
index b2f5f6f..0000000
--- a/src/ShadowDOM/wrappers/HTMLContentElement.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
-
- var OriginalHTMLContentElement = window.HTMLContentElement;
-
- function HTMLContentElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLContentElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLContentElement.prototype, {
- constructor: HTMLContentElement,
-
- get select() {
- return this.getAttribute('select');
- },
- set select(value) {
- this.setAttribute('select', value);
- },
-
- setAttribute: function(n, v) {
- HTMLElement.prototype.setAttribute.call(this, n, v);
- if (String(n).toLowerCase() === 'select')
- this.invalidateShadowRenderer(true);
- }
-
- // getDistributedNodes is added in ShadowRenderer
- });
-
- if (OriginalHTMLContentElement)
- registerWrapper(OriginalHTMLContentElement, HTMLContentElement);
-
- scope.wrappers.HTMLContentElement = HTMLContentElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLElement.js b/src/ShadowDOM/wrappers/HTMLElement.js
deleted file mode 100644
index 8c3a64d..0000000
--- a/src/ShadowDOM/wrappers/HTMLElement.js
+++ /dev/null
@@ -1,351 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var Element = scope.wrappers.Element;
- var defineGetter = scope.defineGetter;
- var enqueueMutation = scope.enqueueMutation;
- var mixin = scope.mixin;
- var nodesWereAdded = scope.nodesWereAdded;
- var nodesWereRemoved = scope.nodesWereRemoved;
- var registerWrapper = scope.registerWrapper;
- var snapshotNodeList = scope.snapshotNodeList;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
- var wrappers = scope.wrappers;
-
- /////////////////////////////////////////////////////////////////////////////
- // innerHTML and outerHTML
-
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
- var escapeAttrRegExp = /[&\u00A0"]/g;
- var escapeDataRegExp = /[&\u00A0<>]/g;
-
- function escapeReplace(c) {
- switch (c) {
- case '&':
- return '&';
- case '<':
- return '<';
- case '>':
- return '>';
- case '"':
- return '"'
- case '\u00A0':
- return ' ';
- }
- }
-
- function escapeAttr(s) {
- return s.replace(escapeAttrRegExp, escapeReplace);
- }
-
- function escapeData(s) {
- return s.replace(escapeDataRegExp, escapeReplace);
- }
-
- function makeSet(arr) {
- var set = {};
- for (var i = 0; i < arr.length; i++) {
- set[arr[i]] = true;
- }
- return set;
- }
-
- // http://www.whatwg.org/specs/web-apps/current-work/#void-elements
- var voidElements = makeSet([
- 'area',
- 'base',
- 'br',
- 'col',
- 'command',
- 'embed',
- 'hr',
- 'img',
- 'input',
- 'keygen',
- 'link',
- 'meta',
- 'param',
- 'source',
- 'track',
- 'wbr'
- ]);
-
- var plaintextParents = makeSet([
- 'style',
- 'script',
- 'xmp',
- 'iframe',
- 'noembed',
- 'noframes',
- 'plaintext',
- 'noscript'
- ]);
-
- var XHTML_NS = 'http://www.w3.org/1999/xhtml';
-
- function needsSelfClosingSlash(node) {
- // if the namespace is not XHTML_NS, this is probably an XML or SVG Document
- // and will need a closing slash on void elements
- if (node.namespaceURI !== XHTML_NS)
- return true;
-
- var doctype = node.ownerDocument.doctype;
- // doctype is null for quirksmode documents
- // publicId and systemId are required for XHTML, and are null for HTML5
- return doctype && doctype.publicId && doctype.systemId;
- }
-
- function getOuterHTML(node, parentNode) {
- switch (node.nodeType) {
- case Node.ELEMENT_NODE:
- var tagName = node.tagName.toLowerCase();
- var s = '<' + tagName;
- var attrs = node.attributes;
- for (var i = 0, attr; attr = attrs[i]; i++) {
- s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
- }
-
- if (voidElements[tagName]) {
- if (needsSelfClosingSlash(node))
- s += '/';
- return s + '>';
- }
-
- return s + '>' + getInnerHTML(node) + '' + tagName + '>';
-
- case Node.TEXT_NODE:
- var data = node.data;
- if (parentNode && plaintextParents[parentNode.localName])
- return data;
- return escapeData(data);
-
- case Node.COMMENT_NODE:
- return '';
-
- default:
- console.error(node);
- throw new Error('not implemented');
- }
- }
-
- function getInnerHTML(node) {
- if (node instanceof wrappers.HTMLTemplateElement)
- node = node.content;
-
- var s = '';
- for (var child = node.firstChild; child; child = child.nextSibling) {
- s += getOuterHTML(child, node);
- }
- return s;
- }
-
- function setInnerHTML(node, value, opt_tagName) {
- var tagName = opt_tagName || 'div';
- node.textContent = '';
- var tempElement = unwrap(node.ownerDocument.createElement(tagName));
- tempElement.innerHTML = value;
- var firstChild;
- while (firstChild = tempElement.firstChild) {
- node.appendChild(wrap(firstChild));
- }
- }
-
- // IE11 does not have MSIE in the user agent string.
- var oldIe = /MSIE/.test(navigator.userAgent);
-
- var OriginalHTMLElement = window.HTMLElement;
- var OriginalHTMLTemplateElement = window.HTMLTemplateElement;
-
- function HTMLElement(node) {
- Element.call(this, node);
- }
- HTMLElement.prototype = Object.create(Element.prototype);
- mixin(HTMLElement.prototype, {
- get innerHTML() {
- return getInnerHTML(this);
- },
- set innerHTML(value) {
- // IE9 does not handle set innerHTML correctly on plaintextParents. It
- // creates element children. For example
- //
- // scriptElement.innerHTML = 'test'
- //
- // Creates a single HTMLAnchorElement child.
- if (oldIe && plaintextParents[this.localName]) {
- this.textContent = value;
- return;
- }
-
- var removedNodes = snapshotNodeList(this.childNodes);
-
- if (this.invalidateShadowRenderer()) {
- if (this instanceof wrappers.HTMLTemplateElement)
- setInnerHTML(this.content, value);
- else
- setInnerHTML(this, value, this.tagName);
-
- // If we have a non native template element we need to handle this
- // manually since setting impl.innerHTML would add the html as direct
- // children and not be moved over to the content fragment.
- } else if (!OriginalHTMLTemplateElement &&
- this instanceof wrappers.HTMLTemplateElement) {
- setInnerHTML(this.content, value);
- } else {
- unsafeUnwrap(this).innerHTML = value;
- }
-
- var addedNodes = snapshotNodeList(this.childNodes);
-
- enqueueMutation(this, 'childList', {
- addedNodes: addedNodes,
- removedNodes: removedNodes
- });
-
- nodesWereRemoved(removedNodes);
- nodesWereAdded(addedNodes, this);
- },
-
- get outerHTML() {
- return getOuterHTML(this, this.parentNode);
- },
- set outerHTML(value) {
- var p = this.parentNode;
- if (p) {
- p.invalidateShadowRenderer();
- var df = frag(p, value);
- p.replaceChild(df, this);
- }
- },
-
- insertAdjacentHTML: function(position, text) {
- var contextElement, refNode;
- switch (String(position).toLowerCase()) {
- case 'beforebegin':
- contextElement = this.parentNode;
- refNode = this;
- break;
- case 'afterend':
- contextElement = this.parentNode;
- refNode = this.nextSibling;
- break;
- case 'afterbegin':
- contextElement = this;
- refNode = this.firstChild;
- break;
- case 'beforeend':
- contextElement = this;
- refNode = null;
- break;
- default:
- return;
- }
-
- var df = frag(contextElement, text);
- contextElement.insertBefore(df, refNode);
- },
-
- get hidden() {
- return this.hasAttribute('hidden');
- },
- set hidden(v) {
- if (v) {
- this.setAttribute('hidden', '');
- } else {
- this.removeAttribute('hidden');
- }
- }
- });
-
- function frag(contextElement, html) {
- // TODO(arv): This does not work with SVG and other non HTML elements.
- var p = unwrap(contextElement.cloneNode(false));
- p.innerHTML = html;
- var df = unwrap(document.createDocumentFragment());
- var c;
- while (c = p.firstChild) {
- df.appendChild(c);
- }
- return wrap(df);
- }
-
- function getter(name) {
- return function() {
- scope.renderAllPending();
- return unsafeUnwrap(this)[name];
- };
- }
-
- function getterRequiresRendering(name) {
- defineGetter(HTMLElement, name, getter(name));
- }
-
- [
- 'clientHeight',
- 'clientLeft',
- 'clientTop',
- 'clientWidth',
- 'offsetHeight',
- 'offsetLeft',
- 'offsetTop',
- 'offsetWidth',
- 'scrollHeight',
- 'scrollWidth',
- ].forEach(getterRequiresRendering);
-
- function getterAndSetterRequiresRendering(name) {
- Object.defineProperty(HTMLElement.prototype, name, {
- get: getter(name),
- set: function(v) {
- scope.renderAllPending();
- unsafeUnwrap(this)[name] = v;
- },
- configurable: true,
- enumerable: true
- });
- }
-
- [
- 'scrollLeft',
- 'scrollTop',
- ].forEach(getterAndSetterRequiresRendering);
-
- function methodRequiresRendering(name) {
- Object.defineProperty(HTMLElement.prototype, name, {
- value: function() {
- scope.renderAllPending();
- return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments);
- },
- configurable: true,
- enumerable: true
- });
- }
-
- [
- 'focus',
- 'getBoundingClientRect',
- 'getClientRects',
- 'scrollIntoView'
- ].forEach(methodRequiresRendering);
-
- // HTMLElement is abstract so we use a subclass that has no members.
- registerWrapper(OriginalHTMLElement, HTMLElement,
- document.createElement('b'));
-
- scope.wrappers.HTMLElement = HTMLElement;
-
- // TODO: Find a better way to share these two with WrapperShadowRoot.
- scope.getInnerHTML = getInnerHTML;
- scope.setInnerHTML = setInnerHTML
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLFormElement.js b/src/ShadowDOM/wrappers/HTMLFormElement.js
deleted file mode 100644
index 9aa71ce..0000000
--- a/src/ShadowDOM/wrappers/HTMLFormElement.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var wrapHTMLCollection = scope.wrapHTMLCollection;
- var unwrap = scope.unwrap;
-
- var OriginalHTMLFormElement = window.HTMLFormElement;
-
- function HTMLFormElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLFormElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLFormElement.prototype, {
- get elements() {
- // Note: technically this should be an HTMLFormControlsCollection, but
- // that inherits from HTMLCollection, so should be good enough. Spec:
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlformcontrolscollection
- return wrapHTMLCollection(unwrap(this).elements);
- }
- });
-
- registerWrapper(OriginalHTMLFormElement, HTMLFormElement,
- document.createElement('form'));
-
- scope.wrappers.HTMLFormElement = HTMLFormElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLImageElement.js b/src/ShadowDOM/wrappers/HTMLImageElement.js
deleted file mode 100644
index 7288f8b..0000000
--- a/src/ShadowDOM/wrappers/HTMLImageElement.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var rewrap = scope.rewrap;
-
- var OriginalHTMLImageElement = window.HTMLImageElement;
-
- function HTMLImageElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLImageElement.prototype = Object.create(HTMLElement.prototype);
-
- registerWrapper(OriginalHTMLImageElement, HTMLImageElement,
- document.createElement('img'));
-
- function Image(width, height) {
- if (!(this instanceof Image)) {
- throw new TypeError(
- 'DOM object constructor cannot be called as a function.');
- }
-
- var node = unwrap(document.createElement('img'));
- HTMLElement.call(this, node);
- rewrap(node, this);
-
- if (width !== undefined)
- node.width = width;
- if (height !== undefined)
- node.height = height;
- }
-
- Image.prototype = HTMLImageElement.prototype;
-
- scope.wrappers.HTMLImageElement = HTMLImageElement;
- scope.wrappers.Image = Image;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLMediaElement.js b/src/ShadowDOM/wrappers/HTMLMediaElement.js
deleted file mode 100644
index 006fe47..0000000
--- a/src/ShadowDOM/wrappers/HTMLMediaElement.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var registerWrapper = scope.registerWrapper;
-
- var OriginalHTMLMediaElement = window.HTMLMediaElement;
-
- if (!OriginalHTMLMediaElement) return;
-
- function HTMLMediaElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLMediaElement.prototype = Object.create(HTMLElement.prototype);
-
- registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement,
- document.createElement('audio'));
-
- scope.wrappers.HTMLMediaElement = HTMLMediaElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLOptionElement.js b/src/ShadowDOM/wrappers/HTMLOptionElement.js
deleted file mode 100644
index 63a7fe8..0000000
--- a/src/ShadowDOM/wrappers/HTMLOptionElement.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var rewrap = scope.rewrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var OriginalHTMLOptionElement = window.HTMLOptionElement;
-
- function trimText(s) {
- return s.replace(/\s+/g, ' ').trim();
- }
-
- function HTMLOptionElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLOptionElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLOptionElement.prototype, {
- get text() {
- return trimText(this.textContent);
- },
- set text(value) {
- this.textContent = trimText(String(value));
- },
- get form() {
- return wrap(unwrap(this).form);
- }
- });
-
- registerWrapper(OriginalHTMLOptionElement, HTMLOptionElement,
- document.createElement('option'));
-
- function Option(text, value, defaultSelected, selected) {
- if (!(this instanceof Option)) {
- throw new TypeError(
- 'DOM object constructor cannot be called as a function.');
- }
-
- var node = unwrap(document.createElement('option'));
- HTMLElement.call(this, node);
- rewrap(node, this);
-
- if (text !== undefined)
- node.text = text;
- if (value !== undefined)
- node.setAttribute('value', value);
- if (defaultSelected === true)
- node.setAttribute('selected', '');
- node.selected = selected === true;
- }
-
- Option.prototype = HTMLOptionElement.prototype;
-
- scope.wrappers.HTMLOptionElement = HTMLOptionElement;
- scope.wrappers.Option = Option;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLSelectElement.js b/src/ShadowDOM/wrappers/HTMLSelectElement.js
deleted file mode 100644
index e091999..0000000
--- a/src/ShadowDOM/wrappers/HTMLSelectElement.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var OriginalHTMLSelectElement = window.HTMLSelectElement;
-
- function HTMLSelectElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLSelectElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLSelectElement.prototype, {
- add: function(element, before) {
- if (typeof before === 'object') // also includes null
- before = unwrap(before);
- unwrap(this).add(unwrap(element), before);
- },
-
- remove: function(indexOrNode) {
- // Spec only allows index but implementations allow index or node.
- // remove() is also allowed which is same as remove(undefined)
- if (indexOrNode === undefined) {
- HTMLElement.prototype.remove.call(this);
- return;
- }
-
- if (typeof indexOrNode === 'object')
- indexOrNode = unwrap(indexOrNode);
-
- unwrap(this).remove(indexOrNode);
- },
-
- get form() {
- return wrap(unwrap(this).form);
- }
- });
-
- registerWrapper(OriginalHTMLSelectElement, HTMLSelectElement,
- document.createElement('select'));
-
- scope.wrappers.HTMLSelectElement = HTMLSelectElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLShadowElement.js b/src/ShadowDOM/wrappers/HTMLShadowElement.js
deleted file mode 100644
index 32ac49b..0000000
--- a/src/ShadowDOM/wrappers/HTMLShadowElement.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var NodeList = scope.wrappers.NodeList;
- var registerWrapper = scope.registerWrapper;
-
- var OriginalHTMLShadowElement = window.HTMLShadowElement;
-
- function HTMLShadowElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);
- HTMLShadowElement.prototype.constructor = HTMLShadowElement;
-
- // getDistributedNodes is added in ShadowRenderer
-
- if (OriginalHTMLShadowElement)
- registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement);
-
- scope.wrappers.HTMLShadowElement = HTMLShadowElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLTableElement.js b/src/ShadowDOM/wrappers/HTMLTableElement.js
deleted file mode 100644
index 446e5ac..0000000
--- a/src/ShadowDOM/wrappers/HTMLTableElement.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
- var wrapHTMLCollection = scope.wrapHTMLCollection;
-
- var OriginalHTMLTableElement = window.HTMLTableElement;
-
- function HTMLTableElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLTableElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLTableElement.prototype, {
- get caption() {
- return wrap(unwrap(this).caption);
- },
- createCaption: function() {
- return wrap(unwrap(this).createCaption());
- },
-
- get tHead() {
- return wrap(unwrap(this).tHead);
- },
- createTHead: function() {
- return wrap(unwrap(this).createTHead());
- },
-
- createTFoot: function() {
- return wrap(unwrap(this).createTFoot());
- },
- get tFoot() {
- return wrap(unwrap(this).tFoot);
- },
-
- get tBodies() {
- return wrapHTMLCollection(unwrap(this).tBodies);
- },
- createTBody: function() {
- return wrap(unwrap(this).createTBody());
- },
-
- get rows() {
- return wrapHTMLCollection(unwrap(this).rows);
- },
- insertRow: function(index) {
- return wrap(unwrap(this).insertRow(index));
- }
- });
-
- registerWrapper(OriginalHTMLTableElement, HTMLTableElement,
- document.createElement('table'));
-
- scope.wrappers.HTMLTableElement = HTMLTableElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLTableRowElement.js b/src/ShadowDOM/wrappers/HTMLTableRowElement.js
deleted file mode 100644
index 3a9a484..0000000
--- a/src/ShadowDOM/wrappers/HTMLTableRowElement.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var wrapHTMLCollection = scope.wrapHTMLCollection;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var OriginalHTMLTableRowElement = window.HTMLTableRowElement;
-
- function HTMLTableRowElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLTableRowElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLTableRowElement.prototype, {
- get cells() {
- return wrapHTMLCollection(unwrap(this).cells);
- },
-
- insertCell: function(index) {
- return wrap(unwrap(this).insertCell(index));
- }
- });
-
- registerWrapper(OriginalHTMLTableRowElement, HTMLTableRowElement,
- document.createElement('tr'));
-
- scope.wrappers.HTMLTableRowElement = HTMLTableRowElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLTableSectionElement.js b/src/ShadowDOM/wrappers/HTMLTableSectionElement.js
deleted file mode 100644
index 871b8b9..0000000
--- a/src/ShadowDOM/wrappers/HTMLTableSectionElement.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var wrapHTMLCollection = scope.wrapHTMLCollection;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var OriginalHTMLTableSectionElement = window.HTMLTableSectionElement;
-
- function HTMLTableSectionElement(node) {
- HTMLElement.call(this, node);
- }
- HTMLTableSectionElement.prototype = Object.create(HTMLElement.prototype);
- mixin(HTMLTableSectionElement.prototype, {
- constructor: HTMLTableSectionElement,
- get rows() {
- return wrapHTMLCollection(unwrap(this).rows);
- },
- insertRow: function(index) {
- return wrap(unwrap(this).insertRow(index));
- }
- });
-
- registerWrapper(OriginalHTMLTableSectionElement, HTMLTableSectionElement,
- document.createElement('thead'));
-
- scope.wrappers.HTMLTableSectionElement = HTMLTableSectionElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLTemplateElement.js b/src/ShadowDOM/wrappers/HTMLTemplateElement.js
deleted file mode 100644
index a145bc2..0000000
--- a/src/ShadowDOM/wrappers/HTMLTemplateElement.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var contentTable = new WeakMap();
- var templateContentsOwnerTable = new WeakMap();
-
- // http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner
- function getTemplateContentsOwner(doc) {
- if (!doc.defaultView)
- return doc;
- var d = templateContentsOwnerTable.get(doc);
- if (!d) {
- // TODO(arv): This should either be a Document or HTMLDocument depending
- // on doc.
- d = doc.implementation.createHTMLDocument('');
- while (d.lastChild) {
- d.removeChild(d.lastChild);
- }
- templateContentsOwnerTable.set(doc, d);
- }
- return d;
- }
-
- function extractContent(templateElement) {
- // templateElement is not a wrapper here.
- var doc = getTemplateContentsOwner(templateElement.ownerDocument);
- var df = unwrap(doc.createDocumentFragment());
- var child;
- while (child = templateElement.firstChild) {
- df.appendChild(child);
- }
- return df;
- }
-
- var OriginalHTMLTemplateElement = window.HTMLTemplateElement;
-
- function HTMLTemplateElement(node) {
- HTMLElement.call(this, node);
- if (!OriginalHTMLTemplateElement) {
- var content = extractContent(node);
- contentTable.set(this, wrap(content));
- }
- }
- HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);
-
- mixin(HTMLTemplateElement.prototype, {
- constructor: HTMLTemplateElement,
- get content() {
- if (OriginalHTMLTemplateElement)
- return wrap(unsafeUnwrap(this).content);
- return contentTable.get(this);
- },
-
- // TODO(arv): cloneNode needs to clone content.
-
- });
-
- if (OriginalHTMLTemplateElement)
- registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement);
-
- scope.wrappers.HTMLTemplateElement = HTMLTemplateElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/HTMLUnknownElement.js b/src/ShadowDOM/wrappers/HTMLUnknownElement.js
deleted file mode 100644
index 606ddae..0000000
--- a/src/ShadowDOM/wrappers/HTMLUnknownElement.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLContentElement = scope.wrappers.HTMLContentElement;
- var HTMLElement = scope.wrappers.HTMLElement;
- var HTMLShadowElement = scope.wrappers.HTMLShadowElement;
- var HTMLTemplateElement = scope.wrappers.HTMLTemplateElement;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
-
- var OriginalHTMLUnknownElement = window.HTMLUnknownElement;
-
- function HTMLUnknownElement(node) {
- switch (node.localName) {
- case 'content':
- return new HTMLContentElement(node);
- case 'shadow':
- return new HTMLShadowElement(node);
- case 'template':
- return new HTMLTemplateElement(node);
- }
- HTMLElement.call(this, node);
- }
- HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype);
- registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement);
- scope.wrappers.HTMLUnknownElement = HTMLUnknownElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Node.js b/src/ShadowDOM/wrappers/Node.js
deleted file mode 100644
index aa97b42..0000000
--- a/src/ShadowDOM/wrappers/Node.js
+++ /dev/null
@@ -1,748 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var EventTarget = scope.wrappers.EventTarget;
- var NodeList = scope.wrappers.NodeList;
- var TreeScope = scope.TreeScope;
- var assert = scope.assert;
- var defineWrapGetter = scope.defineWrapGetter;
- var enqueueMutation = scope.enqueueMutation;
- var getTreeScope = scope.getTreeScope;
- var isWrapper = scope.isWrapper;
- var mixin = scope.mixin;
- var registerTransientObservers = scope.registerTransientObservers;
- var registerWrapper = scope.registerWrapper;
- var setTreeScope = scope.setTreeScope;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
- var wrapIfNeeded = scope.wrapIfNeeded;
- var wrappers = scope.wrappers;
-
- function assertIsNodeWrapper(node) {
- assert(node instanceof Node);
- }
-
- function createOneElementNodeList(node) {
- var nodes = new NodeList();
- nodes[0] = node;
- nodes.length = 1;
- return nodes;
- }
-
- var surpressMutations = false;
-
- /**
- * Called before node is inserted into a node to enqueue its removal from its
- * old parent.
- * @param {!Node} node The node that is about to be removed.
- * @param {!Node} parent The parent node that the node is being removed from.
- * @param {!NodeList} nodes The collected nodes.
- */
- function enqueueRemovalForInsertedNodes(node, parent, nodes) {
- enqueueMutation(parent, 'childList', {
- removedNodes: nodes,
- previousSibling: node.previousSibling,
- nextSibling: node.nextSibling
- });
- }
-
- function enqueueRemovalForInsertedDocumentFragment(df, nodes) {
- enqueueMutation(df, 'childList', {
- removedNodes: nodes
- });
- }
-
- /**
- * Collects nodes from a DocumentFragment or a Node for removal followed
- * by an insertion.
- *
- * This updates the internal pointers for node, previousNode and nextNode.
- */
- function collectNodes(node, parentNode, previousNode, nextNode) {
- if (node instanceof DocumentFragment) {
- var nodes = collectNodesForDocumentFragment(node);
-
- // The extra loop is to work around bugs with DocumentFragments in IE.
- surpressMutations = true;
- for (var i = nodes.length - 1; i >= 0; i--) {
- node.removeChild(nodes[i]);
- nodes[i].parentNode_ = parentNode;
- }
- surpressMutations = false;
-
- for (var i = 0; i < nodes.length; i++) {
- nodes[i].previousSibling_ = nodes[i - 1] || previousNode;
- nodes[i].nextSibling_ = nodes[i + 1] || nextNode;
- }
-
- if (previousNode)
- previousNode.nextSibling_ = nodes[0];
- if (nextNode)
- nextNode.previousSibling_ = nodes[nodes.length - 1];
-
- return nodes;
- }
-
- var nodes = createOneElementNodeList(node);
- var oldParent = node.parentNode;
- if (oldParent) {
- // This will enqueue the mutation record for the removal as needed.
- oldParent.removeChild(node);
- }
-
- node.parentNode_ = parentNode;
- node.previousSibling_ = previousNode;
- node.nextSibling_ = nextNode;
- if (previousNode)
- previousNode.nextSibling_ = node;
- if (nextNode)
- nextNode.previousSibling_ = node;
-
- return nodes;
- }
-
- function collectNodesNative(node) {
- if (node instanceof DocumentFragment)
- return collectNodesForDocumentFragment(node);
-
- var nodes = createOneElementNodeList(node);
- var oldParent = node.parentNode;
- if (oldParent)
- enqueueRemovalForInsertedNodes(node, oldParent, nodes);
- return nodes;
- }
-
- function collectNodesForDocumentFragment(node) {
- var nodes = new NodeList();
- var i = 0;
- for (var child = node.firstChild; child; child = child.nextSibling) {
- nodes[i++] = child;
- }
- nodes.length = i;
- enqueueRemovalForInsertedDocumentFragment(node, nodes);
- return nodes;
- }
-
- function snapshotNodeList(nodeList) {
- // NodeLists are not live at the moment so just return the same object.
- return nodeList;
- }
-
- // http://dom.spec.whatwg.org/#node-is-inserted
- function nodeWasAdded(node, treeScope) {
- setTreeScope(node, treeScope);
- node.nodeIsInserted_();
- }
-
- function nodesWereAdded(nodes, parent) {
- var treeScope = getTreeScope(parent);
- for (var i = 0; i < nodes.length; i++) {
- nodeWasAdded(nodes[i], treeScope);
- }
- }
-
- // http://dom.spec.whatwg.org/#node-is-removed
- function nodeWasRemoved(node) {
- setTreeScope(node, new TreeScope(node, null));
- }
-
- function nodesWereRemoved(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- nodeWasRemoved(nodes[i]);
- }
- }
-
- function ensureSameOwnerDocument(parent, child) {
- var ownerDoc = parent.nodeType === Node.DOCUMENT_NODE ?
- parent : parent.ownerDocument;
- if (ownerDoc !== child.ownerDocument)
- ownerDoc.adoptNode(child);
- }
-
- function adoptNodesIfNeeded(owner, nodes) {
- if (!nodes.length)
- return;
-
- var ownerDoc = owner.ownerDocument;
-
- // All nodes have the same ownerDocument when we get here.
- if (ownerDoc === nodes[0].ownerDocument)
- return;
-
- for (var i = 0; i < nodes.length; i++) {
- scope.adoptNodeNoRemove(nodes[i], ownerDoc);
- }
- }
-
- function unwrapNodesForInsertion(owner, nodes) {
- adoptNodesIfNeeded(owner, nodes);
- var length = nodes.length;
-
- if (length === 1)
- return unwrap(nodes[0]);
-
- var df = unwrap(owner.ownerDocument.createDocumentFragment());
- for (var i = 0; i < length; i++) {
- df.appendChild(unwrap(nodes[i]));
- }
- return df;
- }
-
- function clearChildNodes(wrapper) {
- if (wrapper.firstChild_ !== undefined) {
- var child = wrapper.firstChild_;
- while (child) {
- var tmp = child;
- child = child.nextSibling_;
- tmp.parentNode_ = tmp.previousSibling_ = tmp.nextSibling_ = undefined;
- }
- }
- wrapper.firstChild_ = wrapper.lastChild_ = undefined;
- }
-
- function removeAllChildNodes(wrapper) {
- if (wrapper.invalidateShadowRenderer()) {
- var childWrapper = wrapper.firstChild;
- while (childWrapper) {
- assert(childWrapper.parentNode === wrapper);
- var nextSibling = childWrapper.nextSibling;
- var childNode = unwrap(childWrapper);
- var parentNode = childNode.parentNode;
- if (parentNode)
- originalRemoveChild.call(parentNode, childNode);
- childWrapper.previousSibling_ = childWrapper.nextSibling_ =
- childWrapper.parentNode_ = null;
- childWrapper = nextSibling;
- }
- wrapper.firstChild_ = wrapper.lastChild_ = null;
- } else {
- var node = unwrap(wrapper);
- var child = node.firstChild;
- var nextSibling;
- while (child) {
- nextSibling = child.nextSibling;
- originalRemoveChild.call(node, child);
- child = nextSibling;
- }
- }
- }
-
- function invalidateParent(node) {
- var p = node.parentNode;
- return p && p.invalidateShadowRenderer();
- }
-
- function cleanupNodes(nodes) {
- for (var i = 0, n; i < nodes.length; i++) {
- n = nodes[i];
- n.parentNode.removeChild(n);
- }
- }
-
- var originalImportNode = document.importNode;
- var originalCloneNode = window.Node.prototype.cloneNode;
-
- function cloneNode(node, deep, opt_doc) {
- var clone;
- if (opt_doc)
- clone = wrap(originalImportNode.call(opt_doc, unsafeUnwrap(node), false));
- else
- clone = wrap(originalCloneNode.call(unsafeUnwrap(node), false));
-
- if (deep) {
- for (var child = node.firstChild; child; child = child.nextSibling) {
- clone.appendChild(cloneNode(child, true, opt_doc));
- }
-
- if (node instanceof wrappers.HTMLTemplateElement) {
- var cloneContent = clone.content;
- for (var child = node.content.firstChild;
- child;
- child = child.nextSibling) {
- cloneContent.appendChild(cloneNode(child, true, opt_doc));
- }
- }
- }
- // TODO(arv): Some HTML elements also clone other data like value.
- return clone;
- }
-
- function contains(self, child) {
- if (!child || getTreeScope(self) !== getTreeScope(child))
- return false;
-
- for (var node = child; node; node = node.parentNode) {
- if (node === self)
- return true;
- }
- return false;
- }
-
- var OriginalNode = window.Node;
-
- /**
- * This represents a wrapper of a native DOM node.
- * @param {!Node} original The original DOM node, aka, the visual DOM node.
- * @constructor
- * @extends {EventTarget}
- */
- function Node(original) {
- assert(original instanceof OriginalNode);
-
- EventTarget.call(this, original);
-
- // These properties are used to override the visual references with the
- // logical ones. If the value is undefined it means that the logical is the
- // same as the visual.
-
- /**
- * @type {Node|undefined}
- * @private
- */
- this.parentNode_ = undefined;
-
- /**
- * @type {Node|undefined}
- * @private
- */
- this.firstChild_ = undefined;
-
- /**
- * @type {Node|undefined}
- * @private
- */
- this.lastChild_ = undefined;
-
- /**
- * @type {Node|undefined}
- * @private
- */
- this.nextSibling_ = undefined;
-
- /**
- * @type {Node|undefined}
- * @private
- */
- this.previousSibling_ = undefined;
-
- this.treeScope_ = undefined;
- }
-
- var OriginalDocumentFragment = window.DocumentFragment;
- var originalAppendChild = OriginalNode.prototype.appendChild;
- var originalCompareDocumentPosition =
- OriginalNode.prototype.compareDocumentPosition;
- var originalIsEqualNode = OriginalNode.prototype.isEqualNode;
- var originalInsertBefore = OriginalNode.prototype.insertBefore;
- var originalRemoveChild = OriginalNode.prototype.removeChild;
- var originalReplaceChild = OriginalNode.prototype.replaceChild;
-
- var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent);
-
- var removeChildOriginalHelper = isIEOrEdge ?
- function(parent, child) {
- try {
- originalRemoveChild.call(parent, child);
- } catch (ex) {
- if (!(parent instanceof OriginalDocumentFragment))
- throw ex;
- }
- } :
- function(parent, child) {
- originalRemoveChild.call(parent, child);
- };
-
- Node.prototype = Object.create(EventTarget.prototype);
- mixin(Node.prototype, {
- appendChild: function(childWrapper) {
- return this.insertBefore(childWrapper, null);
- },
-
- insertBefore: function(childWrapper, refWrapper) {
- assertIsNodeWrapper(childWrapper);
-
- var refNode;
- if (refWrapper) {
- if (isWrapper(refWrapper)) {
- refNode = unwrap(refWrapper);
- } else {
- refNode = refWrapper;
- refWrapper = wrap(refNode);
- }
- } else {
- refWrapper = null;
- refNode = null;
- }
-
- refWrapper && assert(refWrapper.parentNode === this);
-
- var nodes;
- var previousNode =
- refWrapper ? refWrapper.previousSibling : this.lastChild;
-
- var useNative = !this.invalidateShadowRenderer() &&
- !invalidateParent(childWrapper);
-
- if (useNative)
- nodes = collectNodesNative(childWrapper);
- else
- nodes = collectNodes(childWrapper, this, previousNode, refWrapper);
-
- if (useNative) {
- ensureSameOwnerDocument(this, childWrapper);
- clearChildNodes(this);
- originalInsertBefore.call(unsafeUnwrap(this), unwrap(childWrapper), refNode);
- } else {
- if (!previousNode)
- this.firstChild_ = nodes[0];
- if (!refWrapper) {
- this.lastChild_ = nodes[nodes.length - 1];
- if (this.firstChild_ === undefined)
- this.firstChild_ = this.firstChild;
- }
-
- var parentNode = refNode ? refNode.parentNode : unsafeUnwrap(this);
-
- // insertBefore refWrapper no matter what the parent is?
- if (parentNode) {
- originalInsertBefore.call(parentNode,
- unwrapNodesForInsertion(this, nodes), refNode);
- } else {
- adoptNodesIfNeeded(this, nodes);
- }
- }
-
- enqueueMutation(this, 'childList', {
- addedNodes: nodes,
- nextSibling: refWrapper,
- previousSibling: previousNode
- });
-
- nodesWereAdded(nodes, this);
-
- return childWrapper;
- },
-
- removeChild: function(childWrapper) {
- assertIsNodeWrapper(childWrapper);
- if (childWrapper.parentNode !== this) {
- // IE has invalid DOM trees at times.
- var found = false;
- var childNodes = this.childNodes;
- for (var ieChild = this.firstChild; ieChild;
- ieChild = ieChild.nextSibling) {
- if (ieChild === childWrapper) {
- found = true;
- break;
- }
- }
- if (!found) {
- // TODO(arv): DOMException
- throw new Error('NotFoundError');
- }
- }
-
- var childNode = unwrap(childWrapper);
- var childWrapperNextSibling = childWrapper.nextSibling;
- var childWrapperPreviousSibling = childWrapper.previousSibling;
-
- if (this.invalidateShadowRenderer()) {
- // We need to remove the real node from the DOM before updating the
- // pointers. This is so that that mutation event is dispatched before
- // the pointers have changed.
- var thisFirstChild = this.firstChild;
- var thisLastChild = this.lastChild;
-
- var parentNode = childNode.parentNode;
- if (parentNode)
- removeChildOriginalHelper(parentNode, childNode);
-
- if (thisFirstChild === childWrapper)
- this.firstChild_ = childWrapperNextSibling;
- if (thisLastChild === childWrapper)
- this.lastChild_ = childWrapperPreviousSibling;
- if (childWrapperPreviousSibling)
- childWrapperPreviousSibling.nextSibling_ = childWrapperNextSibling;
- if (childWrapperNextSibling) {
- childWrapperNextSibling.previousSibling_ =
- childWrapperPreviousSibling;
- }
-
- childWrapper.previousSibling_ = childWrapper.nextSibling_ =
- childWrapper.parentNode_ = undefined;
- } else {
- clearChildNodes(this);
- removeChildOriginalHelper(unsafeUnwrap(this), childNode);
- }
-
- if (!surpressMutations) {
- enqueueMutation(this, 'childList', {
- removedNodes: createOneElementNodeList(childWrapper),
- nextSibling: childWrapperNextSibling,
- previousSibling: childWrapperPreviousSibling
- });
- }
-
- registerTransientObservers(this, childWrapper);
-
- return childWrapper;
- },
-
- replaceChild: function(newChildWrapper, oldChildWrapper) {
- assertIsNodeWrapper(newChildWrapper);
-
- var oldChildNode;
- if (isWrapper(oldChildWrapper)) {
- oldChildNode = unwrap(oldChildWrapper);
- } else {
- oldChildNode = oldChildWrapper;
- oldChildWrapper = wrap(oldChildNode);
- }
-
- if (oldChildWrapper.parentNode !== this) {
- // TODO(arv): DOMException
- throw new Error('NotFoundError');
- }
-
- var nextNode = oldChildWrapper.nextSibling;
- var previousNode = oldChildWrapper.previousSibling;
- var nodes;
-
- var useNative = !this.invalidateShadowRenderer() &&
- !invalidateParent(newChildWrapper);
-
- if (useNative) {
- nodes = collectNodesNative(newChildWrapper);
- } else {
- if (nextNode === newChildWrapper)
- nextNode = newChildWrapper.nextSibling;
- nodes = collectNodes(newChildWrapper, this, previousNode, nextNode);
- }
-
- if (!useNative) {
- if (this.firstChild === oldChildWrapper)
- this.firstChild_ = nodes[0];
- if (this.lastChild === oldChildWrapper)
- this.lastChild_ = nodes[nodes.length - 1];
-
- oldChildWrapper.previousSibling_ = oldChildWrapper.nextSibling_ =
- oldChildWrapper.parentNode_ = undefined;
-
- // replaceChild no matter what the parent is?
- if (oldChildNode.parentNode) {
- originalReplaceChild.call(
- oldChildNode.parentNode,
- unwrapNodesForInsertion(this, nodes),
- oldChildNode);
- }
- } else {
- ensureSameOwnerDocument(this, newChildWrapper);
- clearChildNodes(this);
- originalReplaceChild.call(unsafeUnwrap(this), unwrap(newChildWrapper),
- oldChildNode);
- }
-
- enqueueMutation(this, 'childList', {
- addedNodes: nodes,
- removedNodes: createOneElementNodeList(oldChildWrapper),
- nextSibling: nextNode,
- previousSibling: previousNode
- });
-
- nodeWasRemoved(oldChildWrapper);
- nodesWereAdded(nodes, this);
-
- return oldChildWrapper;
- },
-
- /**
- * Called after a node was inserted. Subclasses override this to invalidate
- * the renderer as needed.
- * @private
- */
- nodeIsInserted_: function() {
- for (var child = this.firstChild; child; child = child.nextSibling) {
- child.nodeIsInserted_();
- }
- },
-
- hasChildNodes: function() {
- return this.firstChild !== null;
- },
-
- /** @type {Node} */
- get parentNode() {
- // If the parentNode has not been overridden, use the original parentNode.
- return this.parentNode_ !== undefined ?
- this.parentNode_ : wrap(unsafeUnwrap(this).parentNode);
- },
-
- /** @type {Node} */
- get firstChild() {
- return this.firstChild_ !== undefined ?
- this.firstChild_ : wrap(unsafeUnwrap(this).firstChild);
- },
-
- /** @type {Node} */
- get lastChild() {
- return this.lastChild_ !== undefined ?
- this.lastChild_ : wrap(unsafeUnwrap(this).lastChild);
- },
-
- /** @type {Node} */
- get nextSibling() {
- return this.nextSibling_ !== undefined ?
- this.nextSibling_ : wrap(unsafeUnwrap(this).nextSibling);
- },
-
- /** @type {Node} */
- get previousSibling() {
- return this.previousSibling_ !== undefined ?
- this.previousSibling_ : wrap(unsafeUnwrap(this).previousSibling);
- },
-
- get parentElement() {
- var p = this.parentNode;
- while (p && p.nodeType !== Node.ELEMENT_NODE) {
- p = p.parentNode;
- }
- return p;
- },
-
- get textContent() {
- // TODO(arv): This should fallback to unsafeUnwrap(this).textContent if there
- // are no shadow trees below or above the context node.
- var s = '';
- for (var child = this.firstChild; child; child = child.nextSibling) {
- if (child.nodeType != Node.COMMENT_NODE) {
- s += child.textContent;
- }
- }
- return s;
- },
- set textContent(textContent) {
- if (textContent == null) textContent = '';
- var removedNodes = snapshotNodeList(this.childNodes);
-
- if (this.invalidateShadowRenderer()) {
- removeAllChildNodes(this);
- if (textContent !== '') {
- var textNode = unsafeUnwrap(this).ownerDocument.createTextNode(textContent);
- this.appendChild(textNode);
- }
- } else {
- clearChildNodes(this);
- unsafeUnwrap(this).textContent = textContent;
- }
-
- var addedNodes = snapshotNodeList(this.childNodes);
-
- enqueueMutation(this, 'childList', {
- addedNodes: addedNodes,
- removedNodes: removedNodes
- });
-
- nodesWereRemoved(removedNodes);
- nodesWereAdded(addedNodes, this);
- },
-
- get childNodes() {
- var wrapperList = new NodeList();
- var i = 0;
- for (var child = this.firstChild; child; child = child.nextSibling) {
- wrapperList[i++] = child;
- }
- wrapperList.length = i;
- return wrapperList;
- },
-
- cloneNode: function(deep) {
- return cloneNode(this, deep);
- },
-
- contains: function(child) {
- return contains(this, wrapIfNeeded(child));
- },
-
- compareDocumentPosition: function(otherNode) {
- // This only wraps, it therefore only operates on the composed DOM and not
- // the logical DOM.
- return originalCompareDocumentPosition.call(unsafeUnwrap(this),
- unwrapIfNeeded(otherNode));
- },
-
- isEqualNode: function(otherNode){
- return originalIsEqualNode.call(unsafeUnwrap(this), unwrapIfNeeded(otherNode));
- },
-
- normalize: function() {
- var nodes = snapshotNodeList(this.childNodes);
- var remNodes = [];
- var s = '';
- var modNode;
-
- for (var i = 0, n; i < nodes.length; i++) {
- n = nodes[i];
- if (n.nodeType === Node.TEXT_NODE) {
- if (!modNode && !n.data.length)
- this.removeChild(n);
- else if (!modNode)
- modNode = n;
- else {
- s += n.data;
- remNodes.push(n);
- }
- } else {
- if (modNode && remNodes.length) {
- modNode.data += s;
- cleanupNodes(remNodes);
- }
- remNodes = [];
- s = '';
- modNode = null;
- if (n.childNodes.length)
- n.normalize();
- }
- }
-
- // handle case where >1 text nodes are the last children
- if (modNode && remNodes.length) {
- modNode.data += s;
- cleanupNodes(remNodes);
- }
- }
- });
-
- defineWrapGetter(Node, 'ownerDocument');
-
- // We use a DocumentFragment as a base and then delete the properties of
- // DocumentFragment.prototype from the wrapper Node. Since delete makes
- // objects slow in some JS engines we recreate the prototype object.
- registerWrapper(OriginalNode, Node, document.createDocumentFragment());
- delete Node.prototype.querySelector;
- delete Node.prototype.querySelectorAll;
- Node.prototype = mixin(Object.create(EventTarget.prototype), Node.prototype);
-
- scope.cloneNode = cloneNode;
- scope.nodeWasAdded = nodeWasAdded;
- scope.nodeWasRemoved = nodeWasRemoved;
- scope.nodesWereAdded = nodesWereAdded;
- scope.nodesWereRemoved = nodesWereRemoved;
- scope.originalInsertBefore = originalInsertBefore;
- scope.originalRemoveChild = originalRemoveChild;
- scope.snapshotNodeList = snapshotNodeList;
- scope.wrappers.Node = Node;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/NodeList.js b/src/ShadowDOM/wrappers/NodeList.js
deleted file mode 100644
index 1461592..0000000
--- a/src/ShadowDOM/wrappers/NodeList.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
-
- var nonEnumDescriptor = {enumerable: false};
-
- function nonEnum(obj, prop) {
- Object.defineProperty(obj, prop, nonEnumDescriptor);
- }
-
- function NodeList() {
- this.length = 0;
- nonEnum(this, 'length');
- }
- NodeList.prototype = {
- item: function(index) {
- return this[index];
- }
- };
- nonEnum(NodeList.prototype, 'item');
-
- function wrapNodeList(list) {
- if (list == null)
- return list;
- var wrapperList = new NodeList();
- for (var i = 0, length = list.length; i < length; i++) {
- wrapperList[i] = wrap(list[i]);
- }
- wrapperList.length = length;
- return wrapperList;
- }
-
- function addWrapNodeListMethod(wrapperConstructor, name) {
- wrapperConstructor.prototype[name] = function() {
- return wrapNodeList(
- unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments));
- };
- }
-
- scope.wrappers.NodeList = NodeList;
- scope.addWrapNodeListMethod = addWrapNodeListMethod;
- scope.wrapNodeList = wrapNodeList;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Range.js b/src/ShadowDOM/wrappers/Range.js
deleted file mode 100644
index e5961ac..0000000
--- a/src/ShadowDOM/wrappers/Range.js
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
- var getTreeScope = scope.getTreeScope;
-
- var OriginalRange = window.Range;
-
- var ShadowRoot = scope.wrappers.ShadowRoot;
-
- function getHost(node) {
- var root = getTreeScope(node).root;
- if (root instanceof ShadowRoot) {
- return root.host;
- }
- return null;
- }
-
- function hostNodeToShadowNode(refNode, offset) {
- if (refNode.shadowRoot) {
- // Note: if the refNode is an element, then selecting a range with and
- // offset equal to refNode.childNodes.length+1 is valid. That is why
- // calling Math.min is necessary to make sure we select valid children.
- offset = Math.min(refNode.childNodes.length - 1, offset);
- var child = refNode.childNodes[offset];
- if (child) {
- var insertionPoint = scope.getDestinationInsertionPoints(child);
- if (insertionPoint.length > 0) {
- var parentNode = insertionPoint[0].parentNode;
- if (parentNode.nodeType == Node.ELEMENT_NODE) {
- refNode = parentNode;
- }
- }
- }
- }
- return refNode;
- }
-
- function shadowNodeToHostNode(node) {
- node = wrap(node);
- return getHost(node) || node;
- }
-
- function Range(impl) {
- setWrapper(impl, this);
- }
- Range.prototype = {
- get startContainer() {
- // Never return a node in the shadow dom.
- return shadowNodeToHostNode(unsafeUnwrap(this).startContainer);
- },
- get endContainer() {
- return shadowNodeToHostNode(unsafeUnwrap(this).endContainer);
- },
- get commonAncestorContainer() {
- return shadowNodeToHostNode(unsafeUnwrap(this).commonAncestorContainer);
- },
- setStart: function(refNode, offset) {
- refNode = hostNodeToShadowNode(refNode, offset);
- unsafeUnwrap(this).setStart(unwrapIfNeeded(refNode), offset);
- },
- setEnd: function(refNode, offset) {
- refNode = hostNodeToShadowNode(refNode, offset);
- unsafeUnwrap(this).setEnd(unwrapIfNeeded(refNode), offset);
- },
- setStartBefore: function(refNode) {
- unsafeUnwrap(this).setStartBefore(unwrapIfNeeded(refNode));
- },
- setStartAfter: function(refNode) {
- unsafeUnwrap(this).setStartAfter(unwrapIfNeeded(refNode));
- },
- setEndBefore: function(refNode) {
- unsafeUnwrap(this).setEndBefore(unwrapIfNeeded(refNode));
- },
- setEndAfter: function(refNode) {
- unsafeUnwrap(this).setEndAfter(unwrapIfNeeded(refNode));
- },
- selectNode: function(refNode) {
- unsafeUnwrap(this).selectNode(unwrapIfNeeded(refNode));
- },
- selectNodeContents: function(refNode) {
- unsafeUnwrap(this).selectNodeContents(unwrapIfNeeded(refNode));
- },
- compareBoundaryPoints: function(how, sourceRange) {
- return unsafeUnwrap(this).compareBoundaryPoints(how, unwrap(sourceRange));
- },
- extractContents: function() {
- return wrap(unsafeUnwrap(this).extractContents());
- },
- cloneContents: function() {
- return wrap(unsafeUnwrap(this).cloneContents());
- },
- insertNode: function(node) {
- unsafeUnwrap(this).insertNode(unwrapIfNeeded(node));
- },
- surroundContents: function(newParent) {
- unsafeUnwrap(this).surroundContents(unwrapIfNeeded(newParent));
- },
- cloneRange: function() {
- return wrap(unsafeUnwrap(this).cloneRange());
- },
- isPointInRange: function(node, offset) {
- return unsafeUnwrap(this).isPointInRange(unwrapIfNeeded(node), offset);
- },
- comparePoint: function(node, offset) {
- return unsafeUnwrap(this).comparePoint(unwrapIfNeeded(node), offset);
- },
- intersectsNode: function(node) {
- return unsafeUnwrap(this).intersectsNode(unwrapIfNeeded(node));
- },
- toString: function() {
- return unsafeUnwrap(this).toString();
- }
- };
-
- // IE9 does not have createContextualFragment.
- if (OriginalRange.prototype.createContextualFragment) {
- Range.prototype.createContextualFragment = function(html) {
- return wrap(unsafeUnwrap(this).createContextualFragment(html));
- };
- }
-
- registerWrapper(window.Range, Range, document.createRange());
-
- scope.wrappers.Range = Range;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/SVGElement.js b/src/ShadowDOM/wrappers/SVGElement.js
deleted file mode 100644
index c6d44e2..0000000
--- a/src/ShadowDOM/wrappers/SVGElement.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var Element = scope.wrappers.Element;
- var HTMLElement = scope.wrappers.HTMLElement;
- var registerWrapper = scope.registerWrapper;
- var defineWrapGetter = scope.defineWrapGetter;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
- var mixin = scope.mixin;
-
- var SVG_NS = 'http://www.w3.org/2000/svg';
- var OriginalSVGElement = window.SVGElement;
-
- var svgTitleElement = document.createElementNS(SVG_NS, 'title');
-
- // IE11 does not have classList for SVG elements. The spec says that classList
- // is an accessor on Element, but IE11 puts classList on HTMLElement, leaving
- // SVGElement without a classList property. We therefore move the accessor for
- // IE11.
- if (!('classList' in svgTitleElement)) {
- var descr = Object.getOwnPropertyDescriptor(Element.prototype, 'classList');
- Object.defineProperty(HTMLElement.prototype, 'classList', descr);
- delete Element.prototype.classList;
- }
-
- function SVGElement(node) {
- Element.call(this, node);
- }
-
- SVGElement.prototype = Object.create(Element.prototype);
- mixin(SVGElement.prototype, {
- get ownerSVGElement() {
- return wrap(unsafeUnwrap(this).ownerSVGElement);
- }
- });
-
- registerWrapper(OriginalSVGElement, SVGElement, document.createElementNS(SVG_NS, 'title'));
-
- scope.wrappers.SVGElement = SVGElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/SVGElementInstance.js b/src/ShadowDOM/wrappers/SVGElementInstance.js
deleted file mode 100644
index 5fd9e46..0000000
--- a/src/ShadowDOM/wrappers/SVGElementInstance.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var EventTarget = scope.wrappers.EventTarget;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
-
- var OriginalSVGElementInstance = window.SVGElementInstance;
- if (!OriginalSVGElementInstance)
- return;
-
- function SVGElementInstance(impl) {
- EventTarget.call(this, impl);
- }
-
- SVGElementInstance.prototype = Object.create(EventTarget.prototype);
- mixin(SVGElementInstance.prototype, {
- /** @type {SVGElement} */
- get correspondingElement() {
- return wrap(unsafeUnwrap(this).correspondingElement);
- },
-
- /** @type {SVGUseElement} */
- get correspondingUseElement() {
- return wrap(unsafeUnwrap(this).correspondingUseElement);
- },
-
- /** @type {SVGElementInstance} */
- get parentNode() {
- return wrap(unsafeUnwrap(this).parentNode);
- },
-
- /** @type {SVGElementInstanceList} */
- get childNodes() {
- throw new Error('Not implemented');
- },
-
- /** @type {SVGElementInstance} */
- get firstChild() {
- return wrap(unsafeUnwrap(this).firstChild);
- },
-
- /** @type {SVGElementInstance} */
- get lastChild() {
- return wrap(unsafeUnwrap(this).lastChild);
- },
-
- /** @type {SVGElementInstance} */
- get previousSibling() {
- return wrap(unsafeUnwrap(this).previousSibling);
- },
-
- /** @type {SVGElementInstance} */
- get nextSibling() {
- return wrap(unsafeUnwrap(this).nextSibling);
- }
- });
-
- registerWrapper(OriginalSVGElementInstance, SVGElementInstance);
-
- scope.wrappers.SVGElementInstance = SVGElementInstance;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/SVGUseElement.js b/src/ShadowDOM/wrappers/SVGUseElement.js
deleted file mode 100644
index 0ff18ed..0000000
--- a/src/ShadowDOM/wrappers/SVGUseElement.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var OriginalSVGUseElement = window.SVGUseElement;
-
- // IE uses SVGElement as parent interface, SVG2 (Blink & Gecko) uses
- // SVGGraphicsElement. Use the element to get the right prototype.
-
- var SVG_NS = 'http://www.w3.org/2000/svg';
- var gWrapper = wrap(document.createElementNS(SVG_NS, 'g'));
- var useElement = document.createElementNS(SVG_NS, 'use');
- var SVGGElement = gWrapper.constructor;
- var parentInterfacePrototype = Object.getPrototypeOf(SVGGElement.prototype);
- var parentInterface = parentInterfacePrototype.constructor;
-
- function SVGUseElement(impl) {
- parentInterface.call(this, impl);
- }
-
- SVGUseElement.prototype = Object.create(parentInterfacePrototype);
-
- // Firefox does not expose instanceRoot.
- if ('instanceRoot' in useElement) {
- mixin(SVGUseElement.prototype, {
- get instanceRoot() {
- return wrap(unwrap(this).instanceRoot);
- },
- get animatedInstanceRoot() {
- return wrap(unwrap(this).animatedInstanceRoot);
- },
- });
- }
-
- registerWrapper(OriginalSVGUseElement, SVGUseElement, useElement);
-
- scope.wrappers.SVGUseElement = SVGUseElement;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Selection.js b/src/ShadowDOM/wrappers/Selection.js
deleted file mode 100644
index d43a677..0000000
--- a/src/ShadowDOM/wrappers/Selection.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
-
- var OriginalSelection = window.Selection;
-
- function Selection(impl) {
- setWrapper(impl, this);
- }
- Selection.prototype = {
- get anchorNode() {
- return wrap(unsafeUnwrap(this).anchorNode);
- },
- get focusNode() {
- return wrap(unsafeUnwrap(this).focusNode);
- },
- addRange: function(range) {
- unsafeUnwrap(this).addRange(unwrapIfNeeded(range));
- },
- collapse: function(node, index) {
- unsafeUnwrap(this).collapse(unwrapIfNeeded(node), index);
- },
- containsNode: function(node, allowPartial) {
- return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial);
- },
- getRangeAt: function(index) {
- return wrap(unsafeUnwrap(this).getRangeAt(index));
- },
- removeRange: function(range) {
- unsafeUnwrap(this).removeRange(unwrap(range));
- },
- selectAllChildren: function(node) {
- unsafeUnwrap(this).selectAllChildren(
- node instanceof ShadowRoot ? unsafeUnwrap(node.host) : unwrapIfNeeded(node)
- );
- },
- toString: function() {
- return unsafeUnwrap(this).toString();
- }
- };
-
- // Not all browsers support Selection.extend. IE does not support extend.
- // https://msdn.microsoft.com/en-us/library/ie/ms535869%28v=vs.85%29.aspx
- // Code that checks if extend exists in the Selection would
- // fail the test if we define extend on the wrapper and it does not exist in
- // the browser Selection object.
- if (OriginalSelection.prototype.extend) {
- Selection.prototype.extend = function(node, offset) {
- unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset);
- };
- }
-
- // WebKit extensions. Not implemented.
- // readonly attribute Node baseNode;
- // readonly attribute long baseOffset;
- // readonly attribute Node extentNode;
- // readonly attribute long extentOffset;
- // [RaisesException] void setBaseAndExtent([Default=Undefined] optional Node baseNode,
- // [Default=Undefined] optional long baseOffset,
- // [Default=Undefined] optional Node extentNode,
- // [Default=Undefined] optional long extentOffset);
- // [RaisesException, ImplementedAs=collapse] void setPosition([Default=Undefined] optional Node node,
- // [Default=Undefined] optional long offset);
-
- registerWrapper(window.Selection, Selection, window.getSelection());
-
- scope.wrappers.Selection = Selection;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/ShadowRoot.js b/src/ShadowDOM/wrappers/ShadowRoot.js
deleted file mode 100644
index 915462e..0000000
--- a/src/ShadowDOM/wrappers/ShadowRoot.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var DocumentFragment = scope.wrappers.DocumentFragment;
- var TreeScope = scope.TreeScope;
- var elementFromPoint = scope.elementFromPoint;
- var getInnerHTML = scope.getInnerHTML;
- var getTreeScope = scope.getTreeScope;
- var mixin = scope.mixin;
- var rewrap = scope.rewrap;
- var setInnerHTML = scope.setInnerHTML;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var shadowHostTable = new WeakMap();
- var nextOlderShadowTreeTable = new WeakMap();
-
- function ShadowRoot(hostWrapper) {
- var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFragment());
- DocumentFragment.call(this, node);
-
- // createDocumentFragment associates the node with a wrapper
- // DocumentFragment instance. Override that.
- rewrap(node, this);
-
- var oldShadowRoot = hostWrapper.shadowRoot;
- nextOlderShadowTreeTable.set(this, oldShadowRoot);
-
- this.treeScope_ =
- new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper));
-
- shadowHostTable.set(this, hostWrapper);
- }
- ShadowRoot.prototype = Object.create(DocumentFragment.prototype);
- mixin(ShadowRoot.prototype, {
- constructor: ShadowRoot,
-
- get innerHTML() {
- return getInnerHTML(this);
- },
- set innerHTML(value) {
- setInnerHTML(this, value);
- this.invalidateShadowRenderer();
- },
-
- get olderShadowRoot() {
- return nextOlderShadowTreeTable.get(this) || null;
- },
-
- get host() {
- return shadowHostTable.get(this) || null;
- },
-
- invalidateShadowRenderer: function() {
- return shadowHostTable.get(this).invalidateShadowRenderer();
- },
-
- elementFromPoint: function(x, y) {
- return elementFromPoint(this, this.ownerDocument, x, y);
- },
-
- getSelection: function() {
- return document.getSelection();
- },
-
- get activeElement() {
- var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement;
- if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
-
- var activeElement = wrap(unwrappedActiveElement);
-
- // Loop while activeElement is not a shallow child of this ShadowRoot.
- while (!this.contains(activeElement)) {
- // Iterate until we hit activeElement's containing ShadowRoot (which
- // isn't this one) or document.
- while (activeElement.parentNode) {
- activeElement = activeElement.parentNode;
- }
-
- // If we've reached a ShadowRoot, move to its host.
- if (activeElement.host) {
- activeElement = activeElement.host;
- // Otherwise, we've reached a document - this ShadowRoot is not an
- // ancestor of the active element.
- } else {
- return null;
- }
- }
-
- return activeElement;
- }
- });
-
- scope.wrappers.ShadowRoot = ShadowRoot;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Text.js b/src/ShadowDOM/wrappers/Text.js
deleted file mode 100644
index 8559e08..0000000
--- a/src/ShadowDOM/wrappers/Text.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var CharacterData = scope.wrappers.CharacterData;
- var enqueueMutation = scope.enqueueMutation;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
-
- function toUInt32(x) {
- return x >>> 0;
- }
-
- var OriginalText = window.Text;
-
- function Text(node) {
- CharacterData.call(this, node);
- }
- Text.prototype = Object.create(CharacterData.prototype);
- mixin(Text.prototype, {
- splitText: function(offset) {
- offset = toUInt32(offset);
- var s = this.data;
- if (offset > s.length)
- throw new Error('IndexSizeError');
- var head = s.slice(0, offset);
- var tail = s.slice(offset);
- this.data = head;
- var newTextNode = this.ownerDocument.createTextNode(tail);
- if (this.parentNode)
- this.parentNode.insertBefore(newTextNode, this.nextSibling);
- return newTextNode;
- }
- });
-
- registerWrapper(OriginalText, Text, document.createTextNode(''));
-
- scope.wrappers.Text = Text;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/TouchEvent.js b/src/ShadowDOM/wrappers/TouchEvent.js
deleted file mode 100644
index 7464411..0000000
--- a/src/ShadowDOM/wrappers/TouchEvent.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var UIEvent = scope.wrappers.UIEvent;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var wrap = scope.wrap;
-
- // TouchEvent is WebKit/Blink only.
- var OriginalTouchEvent = window.TouchEvent;
- if (!OriginalTouchEvent)
- return;
-
- var nativeEvent;
- try {
- nativeEvent = document.createEvent('TouchEvent');
- } catch (ex) {
- // In Chrome creating a TouchEvent fails if the feature is not turned on
- // which it isn't on desktop Chrome.
- return;
- }
-
- var nonEnumDescriptor = {enumerable: false};
-
- function nonEnum(obj, prop) {
- Object.defineProperty(obj, prop, nonEnumDescriptor);
- }
-
- function Touch(impl) {
- setWrapper(impl, this);
- }
-
- Touch.prototype = {
- get target() {
- return wrap(unsafeUnwrap(this).target);
- }
- };
-
- var descr = {
- configurable: true,
- enumerable: true,
- get: null
- };
-
- [
- 'clientX',
- 'clientY',
- 'screenX',
- 'screenY',
- 'pageX',
- 'pageY',
- 'identifier',
- 'webkitRadiusX',
- 'webkitRadiusY',
- 'webkitRotationAngle',
- 'webkitForce'
- ].forEach(function(name) {
- descr.get = function() {
- return unsafeUnwrap(this)[name];
- };
- Object.defineProperty(Touch.prototype, name, descr);
- });
-
- function TouchList() {
- this.length = 0;
- nonEnum(this, 'length');
- }
-
- TouchList.prototype = {
- item: function(index) {
- return this[index];
- }
- };
-
- function wrapTouchList(nativeTouchList) {
- var list = new TouchList();
- for (var i = 0; i < nativeTouchList.length; i++) {
- list[i] = new Touch(nativeTouchList[i]);
- }
- list.length = i;
- return list;
- }
-
- function TouchEvent(impl) {
- UIEvent.call(this, impl);
- }
-
- TouchEvent.prototype = Object.create(UIEvent.prototype);
-
- mixin(TouchEvent.prototype, {
- get touches() {
- return wrapTouchList(unsafeUnwrap(this).touches);
- },
-
- get targetTouches() {
- return wrapTouchList(unsafeUnwrap(this).targetTouches);
- },
-
- get changedTouches() {
- return wrapTouchList(unsafeUnwrap(this).changedTouches);
- },
-
- initTouchEvent: function() {
- // The only way to use this is to reuse the TouchList from an existing
- // TouchEvent. Since this is WebKit/Blink proprietary API we will not
- // implement this until someone screams.
- throw new Error('Not implemented');
- }
- });
-
- registerWrapper(OriginalTouchEvent, TouchEvent, nativeEvent);
-
- scope.wrappers.Touch = Touch;
- scope.wrappers.TouchEvent = TouchEvent;
- scope.wrappers.TouchList = TouchList;
-
-})(window.ShadowDOMPolyfill);
-
diff --git a/src/ShadowDOM/wrappers/TreeWalker.js b/src/ShadowDOM/wrappers/TreeWalker.js
deleted file mode 100644
index 25b7c0d..0000000
--- a/src/ShadowDOM/wrappers/TreeWalker.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * @license
- * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
-
- var OriginalTreeWalker = window.TreeWalker;
-
- function TreeWalker(impl) {
- setWrapper(impl, this);
- }
-
- TreeWalker.prototype = {
- get root() {
- return wrap(unsafeUnwrap(this).root);
- },
- get currentNode() {
- return wrap(unsafeUnwrap(this).currentNode);
- },
- set currentNode(node) {
- unsafeUnwrap(this).currentNode = unwrapIfNeeded(node);
- },
- get filter() {
- return unsafeUnwrap(this).filter;
- },
- parentNode: function() {
- return wrap(unsafeUnwrap(this).parentNode());
- },
- firstChild: function() {
- return wrap(unsafeUnwrap(this).firstChild());
- },
- lastChild: function() {
- return wrap(unsafeUnwrap(this).lastChild());
- },
- previousSibling: function() {
- return wrap(unsafeUnwrap(this).previousSibling());
- },
- previousNode: function() {
- return wrap(unsafeUnwrap(this).previousNode());
- },
- nextNode: function() {
- return wrap(unsafeUnwrap(this).nextNode());
- }
- };
-
- registerWrapper(OriginalTreeWalker, TreeWalker);
-
- scope.wrappers.TreeWalker = TreeWalker;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/WebGLRenderingContext.js b/src/ShadowDOM/wrappers/WebGLRenderingContext.js
deleted file mode 100644
index 223a360..0000000
--- a/src/ShadowDOM/wrappers/WebGLRenderingContext.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var addForwardingProperties = scope.addForwardingProperties;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
-
- var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
-
- // IE10 does not have WebGL.
- if (!OriginalWebGLRenderingContext)
- return;
-
- function WebGLRenderingContext(impl) {
- setWrapper(impl, this);
- }
-
- mixin(WebGLRenderingContext.prototype, {
- get canvas() {
- return wrap(unsafeUnwrap(this).canvas);
- },
-
- texImage2D: function() {
- arguments[5] = unwrapIfNeeded(arguments[5]);
- unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments);
- },
-
- texSubImage2D: function() {
- arguments[6] = unwrapIfNeeded(arguments[6]);
- unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments);
- }
- });
-
- // WebKit has two additional prototypes in the chain for WebGLRenderingContext which are not exposed on `window`: WebGLRenderingContextBase and CanvasRenderingContextBase.
- // CanvasRenderingContextBase has only one getter `canvas`, which is taken care of already, so we skip it.
-
- var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLRenderingContext.prototype);
-
- if (OriginalWebGLRenderingContextBase !== Object.prototype) {
- addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingContext.prototype);
- }
-
- // Blink/WebKit has broken DOM bindings. Usually we would create an instance
- // of the object and pass it into registerWrapper as a "blueprint" but
- // creating WebGL contexts is expensive and might fail so we use a dummy
- // object with dummy instance properties for these broken browsers.
- var instanceProperties = /WebKit/.test(navigator.userAgent) ?
- {drawingBufferHeight: null, drawingBufferWidth: null} : {};
-
- registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext,
- instanceProperties);
-
- scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/Window.js b/src/ShadowDOM/wrappers/Window.js
deleted file mode 100644
index b9e5010..0000000
--- a/src/ShadowDOM/wrappers/Window.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var EventTarget = scope.wrappers.EventTarget;
- var Selection = scope.wrappers.Selection;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var renderAllPending = scope.renderAllPending;
- var unwrap = scope.unwrap;
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var wrap = scope.wrap;
-
- var OriginalWindow = window.Window;
- var originalGetComputedStyle = window.getComputedStyle;
- var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;
- var originalGetSelection = window.getSelection;
-
- function Window(impl) {
- EventTarget.call(this, impl);
- }
- Window.prototype = Object.create(EventTarget.prototype);
-
- OriginalWindow.prototype.getComputedStyle = function(el, pseudo) {
- return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo);
- };
-
- // Mozilla proprietary extension.
- if (originalGetDefaultComputedStyle) {
- OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) {
- return wrap(this || window).getDefaultComputedStyle(
- unwrapIfNeeded(el), pseudo);
- };
- }
-
- OriginalWindow.prototype.getSelection = function() {
- return wrap(this || window).getSelection();
- };
-
- // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065
- delete window.getComputedStyle;
- delete window.getDefaultComputedStyle;
- delete window.getSelection;
-
- ['addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(
- function(name) {
- OriginalWindow.prototype[name] = function() {
- var w = wrap(this || window);
- return w[name].apply(w, arguments);
- };
-
- // Work around for https://bugzilla.mozilla.org/show_bug.cgi?id=943065
- delete window[name];
- });
-
- mixin(Window.prototype, {
- getComputedStyle: function(el, pseudo) {
- renderAllPending();
- return originalGetComputedStyle.call(unwrap(this), unwrapIfNeeded(el),
- pseudo);
- },
- getSelection: function() {
- renderAllPending();
- return new Selection(originalGetSelection.call(unwrap(this)));
- },
-
- get document() {
- return wrap(unwrap(this).document);
- }
- });
-
- // Mozilla proprietary extension.
- if (originalGetDefaultComputedStyle) {
- Window.prototype.getDefaultComputedStyle = function(el, pseudo) {
- renderAllPending();
- return originalGetDefaultComputedStyle.call(unwrap(this),
- unwrapIfNeeded(el),pseudo);
- };
- }
-
- registerWrapper(OriginalWindow, Window, window);
-
- scope.wrappers.Window = Window;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/XMLHttpRequest.js b/src/ShadowDOM/wrappers/XMLHttpRequest.js
deleted file mode 100644
index 5ca6d67..0000000
--- a/src/ShadowDOM/wrappers/XMLHttpRequest.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var unwrapIfNeeded = scope.unwrapIfNeeded;
- var originalSend = XMLHttpRequest.prototype.send;
-
- // Since we only need to adjust XHR.send, we just patch it instead of wrapping
- // the entire object. This happens when FormData is passed.
- XMLHttpRequest.prototype.send = function(obj) {
- return originalSend.call(this, unwrapIfNeeded(obj));
- };
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/elements-with-form-property.js b/src/ShadowDOM/wrappers/elements-with-form-property.js
deleted file mode 100644
index 81c52bb..0000000
--- a/src/ShadowDOM/wrappers/elements-with-form-property.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var HTMLElement = scope.wrappers.HTMLElement;
- var assert = scope.assert;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
-
- var elementsWithFormProperty = [
- 'HTMLButtonElement',
- 'HTMLFieldSetElement',
- 'HTMLInputElement',
- 'HTMLKeygenElement',
- 'HTMLLabelElement',
- 'HTMLLegendElement',
- 'HTMLObjectElement',
- // HTMLOptionElement is handled in HTMLOptionElement.js
- 'HTMLOutputElement',
- // HTMLSelectElement is handled in HTMLSelectElement.js
- 'HTMLTextAreaElement',
- ];
-
- function createWrapperConstructor(name) {
- if (!window[name])
- return;
-
- // Ensure we are not overriding an already existing constructor.
- assert(!scope.wrappers[name]);
-
- var GeneratedWrapper = function(node) {
- // At this point all of them extend HTMLElement.
- HTMLElement.call(this, node);
- }
- GeneratedWrapper.prototype = Object.create(HTMLElement.prototype);
- mixin(GeneratedWrapper.prototype, {
- get form() {
- return wrap(unwrap(this).form);
- },
- });
-
- registerWrapper(window[name], GeneratedWrapper,
- document.createElement(name.slice(4, -7)));
- scope.wrappers[name] = GeneratedWrapper;
- }
-
- elementsWithFormProperty.forEach(createWrapperConstructor);
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/events.js b/src/ShadowDOM/wrappers/events.js
deleted file mode 100644
index 2ac5843..0000000
--- a/src/ShadowDOM/wrappers/events.js
+++ /dev/null
@@ -1,952 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
- var getTreeScope = scope.getTreeScope;
- var mixin = scope.mixin;
- var registerWrapper = scope.registerWrapper;
- var setWrapper = scope.setWrapper;
- var unsafeUnwrap = scope.unsafeUnwrap;
- var unwrap = scope.unwrap;
- var wrap = scope.wrap;
- var wrappers = scope.wrappers;
-
- var wrappedFuns = new WeakMap();
- var listenersTable = new WeakMap();
- var handledEventsTable = new WeakMap();
- var currentlyDispatchingEvents = new WeakMap();
- var targetTable = new WeakMap();
- var currentTargetTable = new WeakMap();
- var relatedTargetTable = new WeakMap();
- var eventPhaseTable = new WeakMap();
- var stopPropagationTable = new WeakMap();
- var stopImmediatePropagationTable = new WeakMap();
- var eventHandlersTable = new WeakMap();
- var eventPathTable = new WeakMap();
-
- function isShadowRoot(node) {
- return node instanceof wrappers.ShadowRoot;
- }
-
- function rootOfNode(node) {
- return getTreeScope(node).root;
- }
-
- // http://w3c.github.io/webcomponents/spec/shadow/#event-paths
- function getEventPath(node, event) {
- var path = [];
- var current = node;
- path.push(current);
- while (current) {
- // 4.1.
- var destinationInsertionPoints = getDestinationInsertionPoints(current);
- if (destinationInsertionPoints && destinationInsertionPoints.length > 0) {
- // 4.1.1
- for (var i = 0; i < destinationInsertionPoints.length; i++) {
- var insertionPoint = destinationInsertionPoints[i];
- // 4.1.1.1
- if (isShadowInsertionPoint(insertionPoint)) {
- var shadowRoot = rootOfNode(insertionPoint);
- // 4.1.1.1.2
- var olderShadowRoot = shadowRoot.olderShadowRoot;
- if (olderShadowRoot)
- path.push(olderShadowRoot);
- }
-
- // 4.1.1.2
- path.push(insertionPoint);
- }
-
- // 4.1.2
- current = destinationInsertionPoints[
- destinationInsertionPoints.length - 1];
-
- // 4.2
- } else {
- if (isShadowRoot(current)) {
- if (inSameTree(node, current) && eventMustBeStopped(event)) {
- // Stop this algorithm
- break;
- }
- current = current.host;
- path.push(current);
-
- // 4.2.2
- } else {
- current = current.parentNode;
- if (current)
- path.push(current);
- }
- }
- }
-
- return path;
- }
-
- // http://w3c.github.io/webcomponents/spec/shadow/#dfn-events-always-stopped
- function eventMustBeStopped(event) {
- if (!event)
- return false;
-
- switch (event.type) {
- case 'abort':
- case 'error':
- case 'select':
- case 'change':
- case 'load':
- case 'reset':
- case 'resize':
- case 'scroll':
- case 'selectstart':
- return true;
- }
- return false;
- }
-
- // http://w3c.github.io/webcomponents/spec/shadow/#dfn-shadow-insertion-point
- function isShadowInsertionPoint(node) {
- return node instanceof HTMLShadowElement;
- // and make sure that there are no shadow precing this?
- // and that there is no content ancestor?
- }
-
- function getDestinationInsertionPoints(node) {
- return scope.getDestinationInsertionPoints(node);
- }
-
- // http://w3c.github.io/webcomponents/spec/shadow/#event-retargeting
- function eventRetargetting(path, currentTarget) {
- if (path.length === 0)
- return currentTarget;
-
- // The currentTarget might be the window object. Use its document for the
- // purpose of finding the retargetted node.
- if (currentTarget instanceof wrappers.Window)
- currentTarget = currentTarget.document;
-
- var currentTargetTree = getTreeScope(currentTarget);
- var originalTarget = path[0];
- var originalTargetTree = getTreeScope(originalTarget);
- var relativeTargetTree =
- lowestCommonInclusiveAncestor(currentTargetTree, originalTargetTree);
-
- for (var i = 0; i < path.length; i++) {
- var node = path[i];
- if (getTreeScope(node) === relativeTargetTree)
- return node;
- }
-
- return path[path.length - 1];
- }
-
- function getTreeScopeAncestors(treeScope) {
- var ancestors = [];
- for (;treeScope; treeScope = treeScope.parent) {
- ancestors.push(treeScope);
- }
- return ancestors;
- }
-
- function lowestCommonInclusiveAncestor(tsA, tsB) {
- var ancestorsA = getTreeScopeAncestors(tsA);
- var ancestorsB = getTreeScopeAncestors(tsB);
-
- var result = null;
- while (ancestorsA.length > 0 && ancestorsB.length > 0) {
- var a = ancestorsA.pop();
- var b = ancestorsB.pop();
- if (a === b)
- result = a;
- else
- break;
- }
- return result;
- }
-
- function getTreeScopeRoot(ts) {
- if (!ts.parent)
- return ts;
- return getTreeScopeRoot(ts.parent);
- }
-
- function relatedTargetResolution(event, currentTarget, relatedTarget) {
- // In case the current target is a window use its document for the purpose
- // of retargetting the related target.
- if (currentTarget instanceof wrappers.Window)
- currentTarget = currentTarget.document;
-
- var currentTargetTree = getTreeScope(currentTarget);
- var relatedTargetTree = getTreeScope(relatedTarget);
-
- var relatedTargetEventPath = getEventPath(relatedTarget, event);
-
- var lowestCommonAncestorTree;
-
- // 4
- var lowestCommonAncestorTree =
- lowestCommonInclusiveAncestor(currentTargetTree, relatedTargetTree);
-
- // 5
- if (!lowestCommonAncestorTree)
- lowestCommonAncestorTree = relatedTargetTree.root;
-
- // 6
- for (var commonAncestorTree = lowestCommonAncestorTree;
- commonAncestorTree;
- commonAncestorTree = commonAncestorTree.parent) {
- // 6.1
- var adjustedRelatedTarget;
- for (var i = 0; i < relatedTargetEventPath.length; i++) {
- var node = relatedTargetEventPath[i];
- if (getTreeScope(node) === commonAncestorTree)
- return node;
- }
- }
-
- return null;
- }
-
- function inSameTree(a, b) {
- return getTreeScope(a) === getTreeScope(b);
- }
-
- var NONE = 0;
- var CAPTURING_PHASE = 1;
- var AT_TARGET = 2;
- var BUBBLING_PHASE = 3;
-
- // pendingError is used to rethrow the first error we got during an event
- // dispatch. The browser actually reports all errors but to do that we would
- // need to rethrow the error asynchronously.
- var pendingError;
-
- function dispatchOriginalEvent(originalEvent) {
- // Make sure this event is only dispatched once.
- if (handledEventsTable.get(originalEvent))
- return;
- handledEventsTable.set(originalEvent, true);
- dispatchEvent(wrap(originalEvent), wrap(originalEvent.target));
- if (pendingError) {
- var err = pendingError;
- pendingError = null;
- throw err;
- }
- }
-
-
- function isLoadLikeEvent(event) {
- switch (event.type) {
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#events-and-the-window-object
- case 'load':
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#unloading-documents
- case 'beforeunload':
- case 'unload':
- return true;
- }
- return false;
- }
-
- function dispatchEvent(event, originalWrapperTarget) {
- if (currentlyDispatchingEvents.get(event))
- throw new Error('InvalidStateError');
-
- currentlyDispatchingEvents.set(event, true);
-
- // Render to ensure that the event path is correct.
- scope.renderAllPending();
- var eventPath;
-
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#events-and-the-window-object
- // All events dispatched on Nodes with a default view, except load events,
- // should propagate to the Window.
-
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end
- var overrideTarget;
- var win;
-
- // Should really be not cancelable too but since Firefox has a bug there
- // we skip that check.
- // https://bugzilla.mozilla.org/show_bug.cgi?id=999456
- if (isLoadLikeEvent(event) && !event.bubbles) {
- var doc = originalWrapperTarget;
- if (doc instanceof wrappers.Document && (win = doc.defaultView)) {
- overrideTarget = doc;
- eventPath = [];
- }
- }
-
- if (!eventPath) {
- if (originalWrapperTarget instanceof wrappers.Window) {
- win = originalWrapperTarget;
- eventPath = [];
- } else {
- eventPath = getEventPath(originalWrapperTarget, event);
-
- if (!isLoadLikeEvent(event)) {
- var doc = eventPath[eventPath.length - 1];
- if (doc instanceof wrappers.Document)
- win = doc.defaultView;
- }
- }
- }
-
- eventPathTable.set(event, eventPath);
-
- if (dispatchCapturing(event, eventPath, win, overrideTarget)) {
- if (dispatchAtTarget(event, eventPath, win, overrideTarget)) {
- dispatchBubbling(event, eventPath, win, overrideTarget);
- }
- }
-
- eventPhaseTable.set(event, NONE);
- currentTargetTable.delete(event, null);
- currentlyDispatchingEvents.delete(event);
-
- return event.defaultPrevented;
- }
-
- function dispatchCapturing(event, eventPath, win, overrideTarget) {
- var phase = CAPTURING_PHASE;
-
- if (win) {
- if (!invoke(win, event, phase, eventPath, overrideTarget))
- return false;
- }
-
- for (var i = eventPath.length - 1; i > 0; i--) {
- if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget))
- return false;
- }
-
- return true;
- }
-
- function dispatchAtTarget(event, eventPath, win, overrideTarget) {
- var phase = AT_TARGET;
- var currentTarget = eventPath[0] || win;
- return invoke(currentTarget, event, phase, eventPath, overrideTarget);
- }
-
- function dispatchBubbling(event, eventPath, win, overrideTarget) {
- var phase = BUBBLING_PHASE;
- for (var i = 1; i < eventPath.length; i++) {
- if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget))
- return;
- }
-
- if (win && eventPath.length > 0) {
- invoke(win, event, phase, eventPath, overrideTarget);
- }
- }
-
- function invoke(currentTarget, event, phase, eventPath, overrideTarget) {
- var listeners = listenersTable.get(currentTarget);
- if (!listeners)
- return true;
-
- var target = overrideTarget || eventRetargetting(eventPath, currentTarget);
-
- if (target === currentTarget) {
- if (phase === CAPTURING_PHASE)
- return true;
-
- if (phase === BUBBLING_PHASE)
- phase = AT_TARGET;
-
- } else if (phase === BUBBLING_PHASE && !event.bubbles) {
- return true;
- }
-
- if ('relatedTarget' in event) {
- var originalEvent = unwrap(event);
- var unwrappedRelatedTarget = originalEvent.relatedTarget;
-
- // X-Tag sets relatedTarget on a CustomEvent. If they do that there is no
- // way to have relatedTarget return the adjusted target but worse is that
- // the originalEvent might not have a relatedTarget so we hit an assert
- // when we try to wrap it.
- if (unwrappedRelatedTarget) {
- // In IE we can get objects that are not EventTargets at this point.
- // Safari does not have an EventTarget interface so revert to checking
- // for addEventListener as an approximation.
- if (unwrappedRelatedTarget instanceof Object &&
- unwrappedRelatedTarget.addEventListener) {
- var relatedTarget = wrap(unwrappedRelatedTarget);
-
- var adjusted =
- relatedTargetResolution(event, currentTarget, relatedTarget);
- if (adjusted === target)
- return true;
- } else {
- adjusted = null;
- }
- relatedTargetTable.set(event, adjusted);
- }
- }
-
- eventPhaseTable.set(event, phase);
- var type = event.type;
-
- var anyRemoved = false;
- targetTable.set(event, target);
- currentTargetTable.set(event, currentTarget);
-
- // Keep track of the invoke depth so that we only clean up the removed
- // listeners if we are in the outermost invoke.
- listeners.depth++;
-
- for (var i = 0, len = listeners.length; i < len; i++) {
- var listener = listeners[i];
- if (listener.removed) {
- anyRemoved = true;
- continue;
- }
-
- if (listener.type !== type ||
- !listener.capture && phase === CAPTURING_PHASE ||
- listener.capture && phase === BUBBLING_PHASE) {
- continue;
- }
-
- try {
- if (typeof listener.handler === 'function')
- listener.handler.call(currentTarget, event);
- else
- listener.handler.handleEvent(event);
-
- if (stopImmediatePropagationTable.get(event))
- return false;
-
- } catch (ex) {
- if (!pendingError)
- pendingError = ex;
- }
- }
-
- listeners.depth--;
-
- if (anyRemoved && listeners.depth === 0) {
- var copy = listeners.slice();
- listeners.length = 0;
- for (var i = 0; i < copy.length; i++) {
- if (!copy[i].removed)
- listeners.push(copy[i]);
- }
- }
-
- return !stopPropagationTable.get(event);
- }
-
- function Listener(type, handler, capture) {
- this.type = type;
- this.handler = handler;
- this.capture = Boolean(capture);
- }
- Listener.prototype = {
- equals: function(that) {
- return this.handler === that.handler && this.type === that.type &&
- this.capture === that.capture;
- },
- get removed() {
- return this.handler === null;
- },
- remove: function() {
- this.handler = null;
- }
- };
-
- var OriginalEvent = window.Event;
- OriginalEvent.prototype.polymerBlackList_ = {
- returnValue: true,
- // TODO(arv): keyLocation is part of KeyboardEvent but Firefox does not
- // support constructable KeyboardEvent so we keep it here for now.
- keyLocation: true
- };
-
- /**
- * Creates a new Event wrapper or wraps an existin native Event object.
- * @param {string|Event} type
- * @param {Object=} options
- * @constructor
- */
- function Event(type, options) {
- if (type instanceof OriginalEvent) {
- var impl = type;
- // In browsers that do not correctly support BeforeUnloadEvent we get to
- // the generic Event wrapper but we still want to ensure we create a
- // BeforeUnloadEvent. Since BeforeUnloadEvent calls super, we need to
- // prevent reentrancty.
- if (!OriginalBeforeUnloadEvent && impl.type === 'beforeunload' &&
- !(this instanceof BeforeUnloadEvent)) {
- return new BeforeUnloadEvent(impl);
- }
- setWrapper(impl, this);
- } else {
- return wrap(constructEvent(OriginalEvent, 'Event', type, options));
- }
- }
- Event.prototype = {
- get target() {
- return targetTable.get(this);
- },
- get currentTarget() {
- return currentTargetTable.get(this);
- },
- get eventPhase() {
- return eventPhaseTable.get(this);
- },
- get path() {
- var eventPath = eventPathTable.get(this);
- if (!eventPath)
- return [];
- // TODO(arv): Event path should contain window.
- return eventPath.slice();
- },
- stopPropagation: function() {
- stopPropagationTable.set(this, true);
- },
- stopImmediatePropagation: function() {
- stopPropagationTable.set(this, true);
- stopImmediatePropagationTable.set(this, true);
- }
- };
-
- // defaultPrevented is broken in IE.
- // https://connect.microsoft.com/IE/feedback/details/790389/event-defaultprevented-returns-false-after-preventdefault-was-called
- var supportsDefaultPrevented = (function() {
- var e = document.createEvent('Event');
- e.initEvent('test', true, true);
- e.preventDefault();
- return e.defaultPrevented;
- })();
-
- if (!supportsDefaultPrevented) {
- Event.prototype.preventDefault = function() {
- if (!this.cancelable)
- return;
-
- unsafeUnwrap(this).preventDefault();
-
- Object.defineProperty(this, 'defaultPrevented', {
- get: function() {
- return true;
- },
- configurable: true
- });
- };
- }
-
- registerWrapper(OriginalEvent, Event, document.createEvent('Event'));
-
- function unwrapOptions(options) {
- if (!options || !options.relatedTarget)
- return options;
- return Object.create(options, {
- relatedTarget: {value: unwrap(options.relatedTarget)}
- });
- }
-
- function registerGenericEvent(name, SuperEvent, prototype) {
- var OriginalEvent = window[name];
- var GenericEvent = function(type, options) {
- if (type instanceof OriginalEvent)
- setWrapper(type, this);
- else
- return wrap(constructEvent(OriginalEvent, name, type, options));
- };
- GenericEvent.prototype = Object.create(SuperEvent.prototype);
- if (prototype)
- mixin(GenericEvent.prototype, prototype);
- if (OriginalEvent) {
- // - Old versions of Safari fails on new FocusEvent (and others?).
- // - IE does not support event constructors.
- // - createEvent('FocusEvent') throws in Firefox.
- // => Try the best practice solution first and fallback to the old way
- // if needed.
- try {
- registerWrapper(OriginalEvent, GenericEvent, new OriginalEvent('temp'));
- } catch (ex) {
- registerWrapper(OriginalEvent, GenericEvent,
- document.createEvent(name));
- }
- }
- return GenericEvent;
- }
-
- var UIEvent = registerGenericEvent('UIEvent', Event);
- var CustomEvent = registerGenericEvent('CustomEvent', Event);
-
- var relatedTargetProto = {
- get relatedTarget() {
- var relatedTarget = relatedTargetTable.get(this);
- // relatedTarget can be null.
- if (relatedTarget !== undefined)
- return relatedTarget;
- return wrap(unwrap(this).relatedTarget);
- }
- };
-
- function getInitFunction(name, relatedTargetIndex) {
- return function() {
- arguments[relatedTargetIndex] = unwrap(arguments[relatedTargetIndex]);
- var impl = unwrap(this);
- impl[name].apply(impl, arguments);
- };
- }
-
- var mouseEventProto = mixin({
- initMouseEvent: getInitFunction('initMouseEvent', 14)
- }, relatedTargetProto);
-
- var focusEventProto = mixin({
- initFocusEvent: getInitFunction('initFocusEvent', 5)
- }, relatedTargetProto);
-
- var MouseEvent = registerGenericEvent('MouseEvent', UIEvent, mouseEventProto);
- var FocusEvent = registerGenericEvent('FocusEvent', UIEvent, focusEventProto);
-
- // In case the browser does not support event constructors we polyfill that
- // by calling `createEvent('Foo')` and `initFooEvent` where the arguments to
- // `initFooEvent` are derived from the registered default event init dict.
- var defaultInitDicts = Object.create(null);
-
- var supportsEventConstructors = (function() {
- try {
- new window.FocusEvent('focus');
- } catch (ex) {
- return false;
- }
- return true;
- })();
-
- /**
- * Constructs a new native event.
- */
- function constructEvent(OriginalEvent, name, type, options) {
- if (supportsEventConstructors)
- return new OriginalEvent(type, unwrapOptions(options));
-
- // Create the arguments from the default dictionary.
- var event = unwrap(document.createEvent(name));
- var defaultDict = defaultInitDicts[name];
- var args = [type];
- Object.keys(defaultDict).forEach(function(key) {
- var v = options != null && key in options ?
- options[key] : defaultDict[key];
- if (key === 'relatedTarget')
- v = unwrap(v);
- args.push(v);
- });
- event['init' + name].apply(event, args);
- return event;
- }
-
- if (!supportsEventConstructors) {
- var configureEventConstructor = function(name, initDict, superName) {
- if (superName) {
- var superDict = defaultInitDicts[superName];
- initDict = mixin(mixin({}, superDict), initDict);
- }
-
- defaultInitDicts[name] = initDict;
- };
-
- // The order of the default event init dictionary keys is important, the
- // arguments to initFooEvent is derived from that.
- configureEventConstructor('Event', {bubbles: false, cancelable: false});
- configureEventConstructor('CustomEvent', {detail: null}, 'Event');
- configureEventConstructor('UIEvent', {view: null, detail: 0}, 'Event');
- configureEventConstructor('MouseEvent', {
- screenX: 0,
- screenY: 0,
- clientX: 0,
- clientY: 0,
- ctrlKey: false,
- altKey: false,
- shiftKey: false,
- metaKey: false,
- button: 0,
- relatedTarget: null
- }, 'UIEvent');
- configureEventConstructor('FocusEvent', {relatedTarget: null}, 'UIEvent');
- }
-
- // Safari 7 does not yet have BeforeUnloadEvent.
- // https://bugs.webkit.org/show_bug.cgi?id=120849
- var OriginalBeforeUnloadEvent = window.BeforeUnloadEvent;
-
- function BeforeUnloadEvent(impl) {
- Event.call(this, impl);
- }
- BeforeUnloadEvent.prototype = Object.create(Event.prototype);
- mixin(BeforeUnloadEvent.prototype, {
- get returnValue() {
- return unsafeUnwrap(this).returnValue;
- },
- set returnValue(v) {
- unsafeUnwrap(this).returnValue = v;
- }
- });
-
- if (OriginalBeforeUnloadEvent)
- registerWrapper(OriginalBeforeUnloadEvent, BeforeUnloadEvent);
-
- function isValidListener(fun) {
- if (typeof fun === 'function')
- return true;
- return fun && fun.handleEvent;
- }
-
- function isMutationEvent(type) {
- switch (type) {
- case 'DOMAttrModified':
- case 'DOMAttributeNameChanged':
- case 'DOMCharacterDataModified':
- case 'DOMElementNameChanged':
- case 'DOMNodeInserted':
- case 'DOMNodeInsertedIntoDocument':
- case 'DOMNodeRemoved':
- case 'DOMNodeRemovedFromDocument':
- case 'DOMSubtreeModified':
- return true;
- }
- return false;
- }
-
- var OriginalEventTarget = window.EventTarget;
-
- /**
- * This represents a wrapper for an EventTarget.
- * @param {!EventTarget} impl The original event target.
- * @constructor
- */
- function EventTarget(impl) {
- setWrapper(impl, this);
- }
-
- // Node and Window have different internal type checks in WebKit so we cannot
- // use the same method as the original function.
- var methodNames = [
- 'addEventListener',
- 'removeEventListener',
- 'dispatchEvent'
- ];
-
- [Node, Window].forEach(function(constructor) {
- var p = constructor.prototype;
- methodNames.forEach(function(name) {
- Object.defineProperty(p, name + '_', {value: p[name]});
- });
- });
-
- function getTargetToListenAt(wrapper) {
- if (wrapper instanceof wrappers.ShadowRoot)
- wrapper = wrapper.host;
- return unwrap(wrapper);
- }
-
- EventTarget.prototype = {
- addEventListener: function(type, fun, capture) {
- if (!isValidListener(fun) || isMutationEvent(type))
- return;
-
- var listener = new Listener(type, fun, capture);
- var listeners = listenersTable.get(this);
- if (!listeners) {
- listeners = [];
- listeners.depth = 0;
- listenersTable.set(this, listeners);
- } else {
- // Might have a duplicate.
- for (var i = 0; i < listeners.length; i++) {
- if (listener.equals(listeners[i]))
- return;
- }
- }
-
- listeners.push(listener);
-
- var target = getTargetToListenAt(this);
- target.addEventListener_(type, dispatchOriginalEvent, true);
- },
- removeEventListener: function(type, fun, capture) {
- capture = Boolean(capture);
- var listeners = listenersTable.get(this);
- if (!listeners)
- return;
- var count = 0, found = false;
- for (var i = 0; i < listeners.length; i++) {
- if (listeners[i].type === type && listeners[i].capture === capture) {
- count++;
- if (listeners[i].handler === fun) {
- found = true;
- listeners[i].remove();
- }
- }
- }
-
- if (found && count === 1) {
- var target = getTargetToListenAt(this);
- target.removeEventListener_(type, dispatchOriginalEvent, true);
- }
- },
- dispatchEvent: function(event) {
- // We want to use the native dispatchEvent because it triggers the default
- // actions (like checking a checkbox). However, if there are no listeners
- // in the composed tree then there are no events that will trigger and
- // listeners in the non composed tree that are part of the event path are
- // not notified.
- //
- // If we find out that there are no listeners in the composed tree we add
- // a temporary listener to the target which makes us get called back even
- // in that case.
-
- var nativeEvent = unwrap(event);
- var eventType = nativeEvent.type;
-
- // Allow dispatching the same event again. This is safe because if user
- // code calls this during an existing dispatch of the same event the
- // native dispatchEvent throws (that is required by the spec).
- handledEventsTable.set(nativeEvent, false);
-
- // Force rendering since we prefer native dispatch and that works on the
- // composed tree.
- scope.renderAllPending();
-
- var tempListener;
- if (!hasListenerInAncestors(this, eventType)) {
- tempListener = function() {};
- this.addEventListener(eventType, tempListener, true);
- }
-
- try {
- return unwrap(this).dispatchEvent_(nativeEvent);
- } finally {
- if (tempListener)
- this.removeEventListener(eventType, tempListener, true);
- }
- }
- };
-
- function hasListener(node, type) {
- var listeners = listenersTable.get(node);
- if (listeners) {
- for (var i = 0; i < listeners.length; i++) {
- if (!listeners[i].removed && listeners[i].type === type)
- return true;
- }
- }
- return false;
- }
-
- function hasListenerInAncestors(target, type) {
- for (var node = unwrap(target); node; node = node.parentNode) {
- if (hasListener(wrap(node), type))
- return true;
- }
- return false;
- }
-
- if (OriginalEventTarget)
- registerWrapper(OriginalEventTarget, EventTarget);
-
- function wrapEventTargetMethods(constructors) {
- forwardMethodsToWrapper(constructors, methodNames);
- }
-
- var originalElementFromPoint = document.elementFromPoint;
-
- function elementFromPoint(self, document, x, y) {
- scope.renderAllPending();
-
- var element =
- wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y));
- if (!element)
- return null;
- var path = getEventPath(element, null);
-
- // scope the path to this TreeScope
- var idx = path.lastIndexOf(self);
- if (idx == -1)
- return null;
- else
- path = path.slice(0, idx);
-
- // TODO(dfreedm): pass idx to eventRetargetting to avoid array copy
- return eventRetargetting(path, self);
- }
-
- /**
- * Returns a function that is to be used as a getter for `onfoo` properties.
- * @param {string} name
- * @return {Function}
- */
- function getEventHandlerGetter(name) {
- return function() {
- var inlineEventHandlers = eventHandlersTable.get(this);
- return inlineEventHandlers && inlineEventHandlers[name] &&
- inlineEventHandlers[name].value || null;
- };
- }
-
- /**
- * Returns a function that is to be used as a setter for `onfoo` properties.
- * @param {string} name
- * @return {Function}
- */
- function getEventHandlerSetter(name) {
- var eventType = name.slice(2);
- return function(value) {
- var inlineEventHandlers = eventHandlersTable.get(this);
- if (!inlineEventHandlers) {
- inlineEventHandlers = Object.create(null);
- eventHandlersTable.set(this, inlineEventHandlers);
- }
-
- var old = inlineEventHandlers[name];
- if (old)
- this.removeEventListener(eventType, old.wrapped, false);
-
- if (typeof value === 'function') {
- var wrapped = function(e) {
- var rv = value.call(this, e);
- if (rv === false)
- e.preventDefault();
- else if (name === 'onbeforeunload' && typeof rv === 'string')
- e.returnValue = rv;
- // mouseover uses true for preventDefault but preventDefault for
- // mouseover is ignored by browsers these day.
- };
-
- this.addEventListener(eventType, wrapped, false);
- inlineEventHandlers[name] = {
- value: value,
- wrapped: wrapped
- };
- }
- };
- }
-
- scope.elementFromPoint = elementFromPoint;
- scope.getEventHandlerGetter = getEventHandlerGetter;
- scope.getEventHandlerSetter = getEventHandlerSetter;
- scope.wrapEventTargetMethods = wrapEventTargetMethods;
- scope.wrappers.BeforeUnloadEvent = BeforeUnloadEvent;
- scope.wrappers.CustomEvent = CustomEvent;
- scope.wrappers.Event = Event;
- scope.wrappers.EventTarget = EventTarget;
- scope.wrappers.FocusEvent = FocusEvent;
- scope.wrappers.MouseEvent = MouseEvent;
- scope.wrappers.UIEvent = UIEvent;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/generic.js b/src/ShadowDOM/wrappers/generic.js
deleted file mode 100644
index 7420c22..0000000
--- a/src/ShadowDOM/wrappers/generic.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var Node = scope.wrappers.Node;
- var GetElementsByInterface = scope.GetElementsByInterface;
- var NonElementParentNodeInterface = scope.NonElementParentNodeInterface;
- var ParentNodeInterface = scope.ParentNodeInterface;
- var SelectorsInterface = scope.SelectorsInterface;
- var mixin = scope.mixin;
- var registerObject = scope.registerObject;
- var registerWrapper = scope.registerWrapper;
-
- var OriginalDocumentFragment = window.DocumentFragment;
-
- function DocumentFragment(node) {
- Node.call(this, node);
- }
-
- DocumentFragment.prototype = Object.create(Node.prototype);
- mixin(DocumentFragment.prototype, ParentNodeInterface);
- mixin(DocumentFragment.prototype, SelectorsInterface);
- mixin(DocumentFragment.prototype, GetElementsByInterface);
- mixin(DocumentFragment.prototype, NonElementParentNodeInterface);
-
- registerWrapper(OriginalDocumentFragment, DocumentFragment, document.createDocumentFragment());
- scope.wrappers.DocumentFragment = DocumentFragment;
-
- var Comment = registerObject(document.createComment(''));
- scope.wrappers.Comment = Comment;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/node-interfaces.js b/src/ShadowDOM/wrappers/node-interfaces.js
deleted file mode 100644
index 622f425..0000000
--- a/src/ShadowDOM/wrappers/node-interfaces.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var NodeList = scope.wrappers.NodeList;
-
- function forwardElement(node) {
- while (node && node.nodeType !== Node.ELEMENT_NODE) {
- node = node.nextSibling;
- }
- return node;
- }
-
- function backwardsElement(node) {
- while (node && node.nodeType !== Node.ELEMENT_NODE) {
- node = node.previousSibling;
- }
- return node;
- }
-
- var ParentNodeInterface = {
- get firstElementChild() {
- return forwardElement(this.firstChild);
- },
-
- get lastElementChild() {
- return backwardsElement(this.lastChild);
- },
-
- get childElementCount() {
- var count = 0;
- for (var child = this.firstElementChild;
- child;
- child = child.nextElementSibling) {
- count++;
- }
- return count;
- },
-
- get children() {
- var wrapperList = new NodeList();
- var i = 0;
- for (var child = this.firstElementChild;
- child;
- child = child.nextElementSibling) {
- wrapperList[i++] = child;
- }
- wrapperList.length = i;
- return wrapperList;
- },
-
- remove: function() {
- var p = this.parentNode;
- if (p)
- p.removeChild(this);
- }
- };
-
- var ChildNodeInterface = {
- get nextElementSibling() {
- return forwardElement(this.nextSibling);
- },
-
- get previousElementSibling() {
- return backwardsElement(this.previousSibling);
- }
- };
-
- var NonElementParentNodeInterface = {
- getElementById: function(id) {
- if (/[ \t\n\r\f]/.test(id))
- return null;
- return this.querySelector('[id="' + id + '"]');
- }
- };
-
- scope.ChildNodeInterface = ChildNodeInterface;
- scope.NonElementParentNodeInterface = NonElementParentNodeInterface;
- scope.ParentNodeInterface = ParentNodeInterface;
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/ShadowDOM/wrappers/override-constructors.js b/src/ShadowDOM/wrappers/override-constructors.js
deleted file mode 100644
index 1937b76..0000000
--- a/src/ShadowDOM/wrappers/override-constructors.js
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- 'use strict';
-
- var isWrapperFor = scope.isWrapperFor;
-
- // This is a list of the elements we currently override the global constructor
- // for.
- var elements = {
- 'a': 'HTMLAnchorElement',
- // Do not create an applet element by default since it shows a warning in
- // IE.
- // https://github.com/Polymer/polymer/issues/217
- // 'applet': 'HTMLAppletElement',
- 'area': 'HTMLAreaElement',
- 'audio': 'HTMLAudioElement',
- 'base': 'HTMLBaseElement',
- 'body': 'HTMLBodyElement',
- 'br': 'HTMLBRElement',
- 'button': 'HTMLButtonElement',
- 'canvas': 'HTMLCanvasElement',
- 'caption': 'HTMLTableCaptionElement',
- 'col': 'HTMLTableColElement',
- // 'command': 'HTMLCommandElement', // Not fully implemented in Gecko.
- 'content': 'HTMLContentElement',
- 'data': 'HTMLDataElement',
- 'datalist': 'HTMLDataListElement',
- 'del': 'HTMLModElement',
- 'dir': 'HTMLDirectoryElement',
- 'div': 'HTMLDivElement',
- 'dl': 'HTMLDListElement',
- 'embed': 'HTMLEmbedElement',
- 'fieldset': 'HTMLFieldSetElement',
- 'font': 'HTMLFontElement',
- 'form': 'HTMLFormElement',
- 'frame': 'HTMLFrameElement',
- 'frameset': 'HTMLFrameSetElement',
- 'h1': 'HTMLHeadingElement',
- 'head': 'HTMLHeadElement',
- 'hr': 'HTMLHRElement',
- 'html': 'HTMLHtmlElement',
- 'iframe': 'HTMLIFrameElement',
- 'img': 'HTMLImageElement',
- 'input': 'HTMLInputElement',
- 'keygen': 'HTMLKeygenElement',
- 'label': 'HTMLLabelElement',
- 'legend': 'HTMLLegendElement',
- 'li': 'HTMLLIElement',
- 'link': 'HTMLLinkElement',
- 'map': 'HTMLMapElement',
- 'marquee': 'HTMLMarqueeElement',
- 'menu': 'HTMLMenuElement',
- 'menuitem': 'HTMLMenuItemElement',
- 'meta': 'HTMLMetaElement',
- 'meter': 'HTMLMeterElement',
- 'object': 'HTMLObjectElement',
- 'ol': 'HTMLOListElement',
- 'optgroup': 'HTMLOptGroupElement',
- 'option': 'HTMLOptionElement',
- 'output': 'HTMLOutputElement',
- 'p': 'HTMLParagraphElement',
- 'param': 'HTMLParamElement',
- 'pre': 'HTMLPreElement',
- 'progress': 'HTMLProgressElement',
- 'q': 'HTMLQuoteElement',
- 'script': 'HTMLScriptElement',
- 'select': 'HTMLSelectElement',
- 'shadow': 'HTMLShadowElement',
- 'source': 'HTMLSourceElement',
- 'span': 'HTMLSpanElement',
- 'style': 'HTMLStyleElement',
- 'table': 'HTMLTableElement',
- 'tbody': 'HTMLTableSectionElement',
- // WebKit and Moz are wrong:
- // https://bugs.webkit.org/show_bug.cgi?id=111469
- // https://bugzilla.mozilla.org/show_bug.cgi?id=848096
- // 'td': 'HTMLTableCellElement',
- 'template': 'HTMLTemplateElement',
- 'textarea': 'HTMLTextAreaElement',
- 'thead': 'HTMLTableSectionElement',
- 'time': 'HTMLTimeElement',
- 'title': 'HTMLTitleElement',
- 'tr': 'HTMLTableRowElement',
- 'track': 'HTMLTrackElement',
- 'ul': 'HTMLUListElement',
- 'video': 'HTMLVideoElement',
- };
-
- function overrideConstructor(tagName) {
- var nativeConstructorName = elements[tagName];
- var nativeConstructor = window[nativeConstructorName];
- if (!nativeConstructor)
- return;
- var element = document.createElement(tagName);
- var wrapperConstructor = element.constructor;
- window[nativeConstructorName] = wrapperConstructor;
- }
-
- Object.keys(elements).forEach(overrideConstructor);
-
- Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) {
- window[name] = scope.wrappers[name]
- });
-
-})(window.ShadowDOMPolyfill);
diff --git a/src/Template/Template.js b/src/Template/Template.js
deleted file mode 100644
index f43e72a..0000000
--- a/src/Template/Template.js
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-// minimal template polyfill
-(function() {
- var needsTemplate = (typeof HTMLTemplateElement === 'undefined');
- // NOTE: Patch document.importNode to work around IE11 bug that
- // casues children of a document fragment imported while
- // there is a mutation observer to not have a parentNode (!?!)
- // This needs to happen *after* patching importNode to fix template cloning
- if (/Trident/.test(navigator.userAgent)) {
- (function() {
- var importNode = document.importNode;
- document.importNode = function() {
- var n = importNode.apply(document, arguments);
- // Copy all children to a new document fragment since
- // this one may be broken
- if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
- var f = document.createDocumentFragment();
- f.appendChild(n);
- return f;
- } else {
- return n;
- }
- };
- })();
- }
-
- // returns true if nested templates cannot be cloned (they cannot be on
- // some impl's like Safari 8)
- var needsCloning = (function() {
- if (!needsTemplate) {
- var t = document.createElement('template');
- var t2 = document.createElement('template');
- t2.content.appendChild(document.createElement('div'));
- t.content.appendChild(t2);
- var clone = t.cloneNode(true);
- return (clone.content.childNodes.length === 0 || clone.content.firstChild.content.childNodes.length === 0);
- }
- })();
-
- var TEMPLATE_TAG = 'template';
- var TemplateImpl = function() {};
-
- if (needsTemplate) {
-
- var contentDoc = document.implementation.createHTMLDocument('template');
- var canDecorate = true;
-
- var templateStyle = document.createElement('style');
- templateStyle.textContent = TEMPLATE_TAG + '{display:none;}';
-
- var head = document.head;
- head.insertBefore(templateStyle, head.firstElementChild);
-
- /**
- Provides a minimal shim for the element.
- */
- TemplateImpl.prototype = Object.create(HTMLElement.prototype);
-
- /**
- The `decorate` method moves element children to the template's `content`.
- NOTE: there is no support for dynamically adding elements to templates.
- */
- TemplateImpl.decorate = function(template) {
- // if the template is decorated, return fast
- if (template.content) {
- return;
- }
- template.content = contentDoc.createDocumentFragment();
- var child;
- while (child = template.firstChild) {
- template.content.appendChild(child);
- }
-
- template.cloneNode = function(deep) {
- return TemplateImpl.cloneNode(this, deep);
- };
-
- // add innerHTML to template, if possible
- // Note: this throws on Safari 7
- if (canDecorate) {
- try {
- Object.defineProperty(template, 'innerHTML', {
- get: function() {
- var o = '';
- for (var e = this.content.firstChild; e; e = e.nextSibling) {
- o += e.outerHTML || escapeData(e.data);
- }
- return o;
- },
- set: function(text) {
- contentDoc.body.innerHTML = text;
- TemplateImpl.bootstrap(contentDoc);
- while (this.content.firstChild) {
- this.content.removeChild(this.content.firstChild);
- }
- while (contentDoc.body.firstChild) {
- this.content.appendChild(contentDoc.body.firstChild);
- }
- },
- configurable: true
- });
-
- } catch (err) {
- canDecorate = false;
- }
- }
- // bootstrap recursively
- TemplateImpl.bootstrap(template.content);
- };
-
- /**
- The `bootstrap` method is called automatically and "fixes" all
- elements in the document referenced by the `doc` argument.
- */
- TemplateImpl.bootstrap = function(doc) {
- var templates = doc.querySelectorAll(TEMPLATE_TAG);
- for (var i=0, l=templates.length, t; (i]/g;
-
- function escapeReplace(c) {
- switch (c) {
- case '&':
- return '&';
- case '<':
- return '<';
- case '>':
- return '>';
- case '\u00A0':
- return ' ';
- }
- }
-
- function escapeData(s) {
- return s.replace(escapeDataRegExp, escapeReplace);
- }
- }
-
- // make cloning/importing work!
- if (needsTemplate || needsCloning) {
- // NOTE: we rely on this cloneNode not causing element upgrade.
- // This means this polyfill must load before the CE polyfill and
- // this would need to be re-worked if a browser supports native CE
- // but not .
- var nativeCloneNode = Node.prototype.cloneNode;
-
- TemplateImpl.cloneNode = function(template, deep) {
- var clone = nativeCloneNode.call(template, false);
- // NOTE: decorate doesn't auto-fix children because they are already
- // decorated so they need special clone fixup.
- if (this.decorate) {
- this.decorate(clone);
- }
- if (deep) {
- // NOTE: use native clone node to make sure CE's wrapped
- // cloneNode does not cause elements to upgrade.
- clone.content.appendChild(
- nativeCloneNode.call(template.content, true));
- // now ensure nested templates are cloned correctly.
- this.fixClonedDom(clone.content, template.content);
- }
- return clone;
- };
-
- // Given a source and cloned subtree, find 's in the cloned
- // subtree and replace them with cloned 's from source.
- // We must do this because only the source templates have proper .content.
- TemplateImpl.fixClonedDom = function(clone, source) {
- // do nothing if cloned node is not an element
- if (!source.querySelectorAll) return;
- // these two lists should be coincident
- var s$ = source.querySelectorAll(TEMPLATE_TAG);
- var t$ = clone.querySelectorAll(TEMPLATE_TAG);
- for (var i=0, l=t$.length, t, s; i's.
- // However, the ownerDocument of the cloned template will be correct!
- // This is because the native import node creates the right document owned
- // subtree and `fixClonedDom` inserts cloned templates into this subtree,
- // thus updating the owner doc.
- document.importNode = function(element, deep) {
- if (element.localName === TEMPLATE_TAG) {
- return TemplateImpl.cloneNode(element, deep);
- } else {
- var dom = originalImportNode.call(document, element, deep);
- if (deep) {
- TemplateImpl.fixClonedDom(dom, element);
- }
- return dom;
- }
- };
-
- if (needsCloning) {
- HTMLTemplateElement.prototype.cloneNode = function(deep) {
- return TemplateImpl.cloneNode(this, deep);
- };
- }
- }
-
- if (needsTemplate) {
- window.HTMLTemplateElement = TemplateImpl;
- }
-
-})();
diff --git a/src/URL/URL.js b/src/URL/URL.js
deleted file mode 100644
index 7eea6f3..0000000
--- a/src/URL/URL.js
+++ /dev/null
@@ -1,616 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-(function(scope) {
- 'use strict';
-
- // feature detect for URL constructor
- var hasWorkingUrl = false;
- if (!scope.forceJURL) {
- try {
- var u = new URL('b', 'http://a');
- u.pathname = 'c%20d';
- hasWorkingUrl = u.href === 'http://a/c%20d';
- } catch(e) {}
- }
-
- if (hasWorkingUrl)
- return;
-
- var relative = Object.create(null);
- relative['ftp'] = 21;
- relative['file'] = 0;
- relative['gopher'] = 70;
- relative['http'] = 80;
- relative['https'] = 443;
- relative['ws'] = 80;
- relative['wss'] = 443;
-
- var relativePathDotMapping = Object.create(null);
- relativePathDotMapping['%2e'] = '.';
- relativePathDotMapping['.%2e'] = '..';
- relativePathDotMapping['%2e.'] = '..';
- relativePathDotMapping['%2e%2e'] = '..';
-
- function isRelativeScheme(scheme) {
- return relative[scheme] !== undefined;
- }
-
- function invalid() {
- clear.call(this);
- this._isInvalid = true;
- }
-
- function IDNAToASCII(h) {
- if ('' == h) {
- invalid.call(this)
- }
- // XXX
- return h.toLowerCase()
- }
-
- function percentEscape(c) {
- var unicode = c.charCodeAt(0);
- if (unicode > 0x20 &&
- unicode < 0x7F &&
- // " # < > ? `
- [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) == -1
- ) {
- return c;
- }
- return encodeURIComponent(c);
- }
-
- function percentEscapeQuery(c) {
- // XXX This actually needs to encode c using encoding and then
- // convert the bytes one-by-one.
-
- var unicode = c.charCodeAt(0);
- if (unicode > 0x20 &&
- unicode < 0x7F &&
- // " # < > ` (do not escape '?')
- [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) == -1
- ) {
- return c;
- }
- return encodeURIComponent(c);
- }
-
- var EOF = undefined,
- ALPHA = /[a-zA-Z]/,
- ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
-
- function parse(input, stateOverride, base) {
- function err(message) {
- errors.push(message)
- }
-
- var state = stateOverride || 'scheme start',
- cursor = 0,
- buffer = '',
- seenAt = false,
- seenBracket = false,
- errors = [];
-
- loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
- var c = input[cursor];
- switch (state) {
- case 'scheme start':
- if (c && ALPHA.test(c)) {
- buffer += c.toLowerCase(); // ASCII-safe
- state = 'scheme';
- } else if (!stateOverride) {
- buffer = '';
- state = 'no scheme';
- continue;
- } else {
- err('Invalid scheme.');
- break loop;
- }
- break;
-
- case 'scheme':
- if (c && ALPHANUMERIC.test(c)) {
- buffer += c.toLowerCase(); // ASCII-safe
- } else if (':' == c) {
- this._scheme = buffer;
- buffer = '';
- if (stateOverride) {
- break loop;
- }
- if (isRelativeScheme(this._scheme)) {
- this._isRelative = true;
- }
- if ('file' == this._scheme) {
- state = 'relative';
- } else if (this._isRelative && base && base._scheme == this._scheme) {
- state = 'relative or authority';
- } else if (this._isRelative) {
- state = 'authority first slash';
- } else {
- state = 'scheme data';
- }
- } else if (!stateOverride) {
- buffer = '';
- cursor = 0;
- state = 'no scheme';
- continue;
- } else if (EOF == c) {
- break loop;
- } else {
- err('Code point not allowed in scheme: ' + c)
- break loop;
- }
- break;
-
- case 'scheme data':
- if ('?' == c) {
- this._query = '?';
- state = 'query';
- } else if ('#' == c) {
- this._fragment = '#';
- state = 'fragment';
- } else {
- // XXX error handling
- if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._schemeData += percentEscape(c);
- }
- }
- break;
-
- case 'no scheme':
- if (!base || !(isRelativeScheme(base._scheme))) {
- err('Missing scheme.');
- invalid.call(this);
- } else {
- state = 'relative';
- continue;
- }
- break;
-
- case 'relative or authority':
- if ('/' == c && '/' == input[cursor+1]) {
- state = 'authority ignore slashes';
- } else {
- err('Expected /, got: ' + c);
- state = 'relative';
- continue
- }
- break;
-
- case 'relative':
- this._isRelative = true;
- if ('file' != this._scheme)
- this._scheme = base._scheme;
- if (EOF == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = base._query;
- this._username = base._username;
- this._password = base._password;
- break loop;
- } else if ('/' == c || '\\' == c) {
- if ('\\' == c)
- err('\\ is an invalid code point.');
- state = 'relative slash';
- } else if ('?' == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = '?';
- this._username = base._username;
- this._password = base._password;
- state = 'query';
- } else if ('#' == c) {
- this._host = base._host;
- this._port = base._port;
- this._path = base._path.slice();
- this._query = base._query;
- this._fragment = '#';
- this._username = base._username;
- this._password = base._password;
- state = 'fragment';
- } else {
- var nextC = input[cursor+1]
- var nextNextC = input[cursor+2]
- if (
- 'file' != this._scheme || !ALPHA.test(c) ||
- (nextC != ':' && nextC != '|') ||
- (EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?' != nextNextC && '#' != nextNextC)) {
- this._host = base._host;
- this._port = base._port;
- this._username = base._username;
- this._password = base._password;
- this._path = base._path.slice();
- this._path.pop();
- }
- state = 'relative path';
- continue;
- }
- break;
-
- case 'relative slash':
- if ('/' == c || '\\' == c) {
- if ('\\' == c) {
- err('\\ is an invalid code point.');
- }
- if ('file' == this._scheme) {
- state = 'file host';
- } else {
- state = 'authority ignore slashes';
- }
- } else {
- if ('file' != this._scheme) {
- this._host = base._host;
- this._port = base._port;
- this._username = base._username;
- this._password = base._password;
- }
- state = 'relative path';
- continue;
- }
- break;
-
- case 'authority first slash':
- if ('/' == c) {
- state = 'authority second slash';
- } else {
- err("Expected '/', got: " + c);
- state = 'authority ignore slashes';
- continue;
- }
- break;
-
- case 'authority second slash':
- state = 'authority ignore slashes';
- if ('/' != c) {
- err("Expected '/', got: " + c);
- continue;
- }
- break;
-
- case 'authority ignore slashes':
- if ('/' != c && '\\' != c) {
- state = 'authority';
- continue;
- } else {
- err('Expected authority, got: ' + c);
- }
- break;
-
- case 'authority':
- if ('@' == c) {
- if (seenAt) {
- err('@ already seen.');
- buffer += '%40';
- }
- seenAt = true;
- for (var i = 0; i < buffer.length; i++) {
- var cp = buffer[i];
- if ('\t' == cp || '\n' == cp || '\r' == cp) {
- err('Invalid whitespace in authority.');
- continue;
- }
- // XXX check URL code points
- if (':' == cp && null === this._password) {
- this._password = '';
- continue;
- }
- var tempC = percentEscape(cp);
- (null !== this._password) ? this._password += tempC : this._username += tempC;
- }
- buffer = '';
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- cursor -= buffer.length;
- buffer = '';
- state = 'host';
- continue;
- } else {
- buffer += c;
- }
- break;
-
- case 'file host':
- if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':' || buffer[1] == '|')) {
- state = 'relative path';
- } else if (buffer.length == 0) {
- state = 'relative path start';
- } else {
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'relative path start';
- }
- continue;
- } else if ('\t' == c || '\n' == c || '\r' == c) {
- err('Invalid whitespace in file host.');
- } else {
- buffer += c;
- }
- break;
-
- case 'host':
- case 'hostname':
- if (':' == c && !seenBracket) {
- // XXX host parsing
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'port';
- if ('hostname' == stateOverride) {
- break loop;
- }
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) {
- this._host = IDNAToASCII.call(this, buffer);
- buffer = '';
- state = 'relative path start';
- if (stateOverride) {
- break loop;
- }
- continue;
- } else if ('\t' != c && '\n' != c && '\r' != c) {
- if ('[' == c) {
- seenBracket = true;
- } else if (']' == c) {
- seenBracket = false;
- }
- buffer += c;
- } else {
- err('Invalid code point in host/hostname: ' + c);
- }
- break;
-
- case 'port':
- if (/[0-9]/.test(c)) {
- buffer += c;
- } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c || stateOverride) {
- if ('' != buffer) {
- var temp = parseInt(buffer, 10);
- if (temp != relative[this._scheme]) {
- this._port = temp + '';
- }
- buffer = '';
- }
- if (stateOverride) {
- break loop;
- }
- state = 'relative path start';
- continue;
- } else if ('\t' == c || '\n' == c || '\r' == c) {
- err('Invalid code point in port: ' + c);
- } else {
- invalid.call(this);
- }
- break;
-
- case 'relative path start':
- if ('\\' == c)
- err("'\\' not allowed in path.");
- state = 'relative path';
- if ('/' != c && '\\' != c) {
- continue;
- }
- break;
-
- case 'relative path':
- if (EOF == c || '/' == c || '\\' == c || (!stateOverride && ('?' == c || '#' == c))) {
- if ('\\' == c) {
- err('\\ not allowed in relative path.');
- }
- var tmp;
- if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
- buffer = tmp;
- }
- if ('..' == buffer) {
- this._path.pop();
- if ('/' != c && '\\' != c) {
- this._path.push('');
- }
- } else if ('.' == buffer && '/' != c && '\\' != c) {
- this._path.push('');
- } else if ('.' != buffer) {
- if ('file' == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == '|') {
- buffer = buffer[0] + ':';
- }
- this._path.push(buffer);
- }
- buffer = '';
- if ('?' == c) {
- this._query = '?';
- state = 'query';
- } else if ('#' == c) {
- this._fragment = '#';
- state = 'fragment';
- }
- } else if ('\t' != c && '\n' != c && '\r' != c) {
- buffer += percentEscape(c);
- }
- break;
-
- case 'query':
- if (!stateOverride && '#' == c) {
- this._fragment = '#';
- state = 'fragment';
- } else if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._query += percentEscapeQuery(c);
- }
- break;
-
- case 'fragment':
- if (EOF != c && '\t' != c && '\n' != c && '\r' != c) {
- this._fragment += c;
- }
- break;
- }
-
- cursor++;
- }
- }
-
- function clear() {
- this._scheme = '';
- this._schemeData = '';
- this._username = '';
- this._password = null;
- this._host = '';
- this._port = '';
- this._path = [];
- this._query = '';
- this._fragment = '';
- this._isInvalid = false;
- this._isRelative = false;
- }
-
- // Does not process domain names or IP addresses.
- // Does not handle encoding for the query parameter.
- function jURL(url, base /* , encoding */) {
- if (base !== undefined && !(base instanceof jURL))
- base = new jURL(String(base));
-
- this._url = url;
- clear.call(this);
-
- var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
- // encoding = encoding || 'utf-8'
-
- parse.call(this, input, null, base);
- }
-
- jURL.prototype = {
- toString: function() {
- return this.href;
- },
- get href() {
- if (this._isInvalid)
- return this._url;
-
- var authority = '';
- if ('' != this._username || null != this._password) {
- authority = this._username +
- (null != this._password ? ':' + this._password : '') + '@';
- }
-
- return this.protocol +
- (this._isRelative ? '//' + authority + this.host : '') +
- this.pathname + this._query + this._fragment;
- },
- set href(href) {
- clear.call(this);
- parse.call(this, href);
- },
-
- get protocol() {
- return this._scheme + ':';
- },
- set protocol(protocol) {
- if (this._isInvalid)
- return;
- parse.call(this, protocol + ':', 'scheme start');
- },
-
- get host() {
- return this._isInvalid ? '' : this._port ?
- this._host + ':' + this._port : this._host;
- },
- set host(host) {
- if (this._isInvalid || !this._isRelative)
- return;
- parse.call(this, host, 'host');
- },
-
- get hostname() {
- return this._host;
- },
- set hostname(hostname) {
- if (this._isInvalid || !this._isRelative)
- return;
- parse.call(this, hostname, 'hostname');
- },
-
- get port() {
- return this._port;
- },
- set port(port) {
- if (this._isInvalid || !this._isRelative)
- return;
- parse.call(this, port, 'port');
- },
-
- get pathname() {
- return this._isInvalid ? '' : this._isRelative ?
- '/' + this._path.join('/') : this._schemeData;
- },
- set pathname(pathname) {
- if (this._isInvalid || !this._isRelative)
- return;
- this._path = [];
- parse.call(this, pathname, 'relative path start');
- },
-
- get search() {
- return this._isInvalid || !this._query || '?' == this._query ?
- '' : this._query;
- },
- set search(search) {
- if (this._isInvalid || !this._isRelative)
- return;
- this._query = '?';
- if ('?' == search[0])
- search = search.slice(1);
- parse.call(this, search, 'query');
- },
-
- get hash() {
- return this._isInvalid || !this._fragment || '#' == this._fragment ?
- '' : this._fragment;
- },
- set hash(hash) {
- if (this._isInvalid)
- return;
- this._fragment = '#';
- if ('#' == hash[0])
- hash = hash.slice(1);
- parse.call(this, hash, 'fragment');
- },
-
- get origin() {
- var host;
- if (this._isInvalid || !this._scheme) {
- return '';
- }
- // javascript: Gecko returns String(""), WebKit/Blink String("null")
- // Gecko throws error for "data://"
- // data: Gecko returns "", Blink returns "data://", WebKit returns "null"
- // Gecko returns String("") for file: mailto:
- // WebKit/Blink returns String("SCHEME://") for file: mailto:
- switch (this._scheme) {
- case 'data':
- case 'file':
- case 'javascript':
- case 'mailto':
- return 'null';
- }
- host = this.host;
- if (!host) {
- return '';
- }
- return this._scheme + '://' + host;
- }
- };
-
- // Copy over the static methods
- var OriginalURL = scope.URL;
- if (OriginalURL) {
- jURL.createObjectURL = function(blob) {
- // IE extension allows a second optional options argument.
- // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
- return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
- };
- jURL.revokeObjectURL = function(url) {
- OriginalURL.revokeObjectURL(url);
- };
- }
-
- scope.URL = jURL;
-
-})(self);
diff --git a/src/WeakMap/WeakMap.js b/src/WeakMap/WeakMap.js
deleted file mode 100644
index fae6e14..0000000
--- a/src/WeakMap/WeakMap.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-if (typeof WeakMap === 'undefined') {
- (function() {
- var defineProperty = Object.defineProperty;
- var counter = Date.now() % 1e9;
-
- var WeakMap = function() {
- this.name = '__st' + (Math.random() * 1e9 >>> 0) + (counter++ + '__');
- };
-
- WeakMap.prototype = {
- set: function(key, value) {
- var entry = key[this.name];
- if (entry && entry[0] === key)
- entry[1] = value;
- else
- defineProperty(key, this.name, {value: [key, value], writable: true});
- return this;
- },
- get: function(key) {
- var entry;
- return (entry = key[this.name]) && entry[0] === key ?
- entry[1] : undefined;
- },
- delete: function(key) {
- var entry = key[this.name];
- if (!entry || entry[0] !== key) return false;
- entry[0] = entry[1] = undefined;
- return true;
- },
- has: function(key) {
- var entry = key[this.name];
- if (!entry) return false;
- return entry[0] === key;
- }
- };
-
- window.WeakMap = WeakMap;
- })();
-}
diff --git a/src/WebComponents/Promise.js b/src/WebComponents/Promise.js
deleted file mode 100644
index f7925ad..0000000
--- a/src/WebComponents/Promise.js
+++ /dev/null
@@ -1,186 +0,0 @@
-(function() {
-
- if (!window.Promise) {
-
- function MakePromise (asap) {
- function Promise(fn) {
- if (typeof this !== 'object' || typeof fn !== 'function') throw new TypeError();
- this._state = null;
- this._value = null;
- this._deferreds = []
-
- doResolve(fn, resolve.bind(this), reject.bind(this));
- }
-
- function handle(deferred) {
- var me = this;
- if (this._state === null) {
- this._deferreds.push(deferred);
- return
- }
- asap(function() {
- var cb = me._state ? deferred.onFulfilled : deferred.onRejected
- if (typeof cb !== 'function') {
- (me._state ? deferred.resolve : deferred.reject)(me._value);
- return;
- }
- var ret;
- try {
- ret = cb(me._value);
- }
- catch (e) {
- deferred.reject(e);
- return;
- }
- deferred.resolve(ret);
- })
- }
-
- function resolve(newValue) {
- try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
- if (newValue === this) throw new TypeError();
- if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
- var then = newValue.then;
- if (typeof then === 'function') {
- doResolve(then.bind(newValue), resolve.bind(this), reject.bind(this));
- return;
- }
- }
- this._state = true;
- this._value = newValue;
- finale.call(this);
- } catch (e) { reject.call(this, e); }
- }
-
- function reject(newValue) {
- this._state = false;
- this._value = newValue;
- finale.call(this);
- }
-
- function finale() {
- for (var i = 0, len = this._deferreds.length; i < len; i++) {
- handle.call(this, this._deferreds[i]);
- }
- this._deferreds = null;
- }
-
- /**
- * Take a potentially misbehaving resolver function and make sure
- * onFulfilled and onRejected are only called once.
- *
- * Makes no guarantees about asynchrony.
- */
- function doResolve(fn, onFulfilled, onRejected) {
- var done = false;
- try {
- fn(function (value) {
- if (done) return;
- done = true;
- onFulfilled(value);
- }, function (reason) {
- if (done) return;
- done = true;
- onRejected(reason);
- })
- } catch (ex) {
- if (done) return;
- done = true;
- onRejected(ex);
- }
- }
-
- Promise.prototype['catch'] = function (onRejected) {
- return this.then(null, onRejected);
- };
-
- Promise.prototype.then = function(onFulfilled, onRejected) {
- var me = this;
- return new Promise(function(resolve, reject) {
- handle.call(me, {
- onFulfilled: onFulfilled,
- onRejected: onRejected,
- resolve: resolve,
- reject: reject
- });
- })
- };
-
- Promise.resolve = function (value) {
- if (value && typeof value === 'object' && value.constructor === Promise) {
- return value;
- }
-
- return new Promise(function (resolve) {
- resolve(value);
- });
- };
-
- Promise.reject = function (value) {
- return new Promise(function (resolve, reject) {
- reject(value);
- });
- };
-
-
- return Promise;
- }
-
-
- function makeAsync() {
- var twiddle = document.createTextNode('');
- var content = 0;
- return function(callback) {
- // To preserve timing with Promise microtasks
- // we create a new observer for every callback.
- var observer = new MutationObserver(function(mxns) {
- observer.disconnect();
- callback();
- });
- observer.observe(twiddle, {characterData: true});
- twiddle.textContent = content++;
- }
- }
-
- window.Promise = MakePromise(makeAsync());
-
- window.Promise.all = function () {
- var args = Array.prototype.slice.call(arguments.length === 1 && Array.isArray(arguments[0]) ? arguments[0] : arguments);
-
- return new Promise(function (resolve, reject) {
- if (args.length === 0) return resolve([]);
- var remaining = args.length;
- function res(i, val) {
- try {
- if (val && (typeof val === 'object' || typeof val === 'function')) {
- var then = val.then;
- if (typeof then === 'function') {
- then.call(val, function (val) { res(i, val) }, reject);
- return;
- }
- }
- args[i] = val;
- if (--remaining === 0) {
- resolve(args);
- }
- } catch (ex) {
- reject(ex);
- }
- }
- for (var i = 0; i < args.length; i++) {
- res(i, args[i]);
- }
- });
- };
-
- window.Promise.race = function (values) {
- return new Promise(function (resolve, reject) {
- for(var i = 0, len = values.length; i < len; i++) {
- values[i].then(resolve, reject);
- }
- });
- };
-
- }
-
-})();
\ No newline at end of file
diff --git a/src/WebComponents/bc.js b/src/WebComponents/bc.js
deleted file mode 100644
index d6183a6..0000000
--- a/src/WebComponents/bc.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
-
- // alias to Platform for bc
- window.Platform = scope;
-
-})(window.WebComponents);
diff --git a/src/WebComponents/build-lite.json b/src/WebComponents/build-lite.json
deleted file mode 100644
index 17199b2..0000000
--- a/src/WebComponents/build-lite.json
+++ /dev/null
@@ -1,15 +0,0 @@
-[
- "build/boot-lite.js",
- "../URL/URL.js",
- "../WeakMap/WeakMap.js",
- "../MutationObserver/MutationObserver.js",
- "../Template/Template.js",
- "../HTMLImports/build.json",
- "Promise.js",
- "../../custom-elements/custom-elements.min.js",
- "../../shadydom/shadydom.min.js",
- "../../shadycss/shadycss.min.js",
- "lang.js",
- "dom.js",
- "unresolved.js"
-]
diff --git a/src/WebComponents/build.json b/src/WebComponents/build.json
deleted file mode 100644
index 89ea0da..0000000
--- a/src/WebComponents/build.json
+++ /dev/null
@@ -1,15 +0,0 @@
-[
- "build/boot.js",
- "build/if-poly.js",
- "../ShadowDOM/build.json",
- "../ShadowCSS/ShadowCSS.js",
- "build/end-if.js",
- "shadowdom.js",
- "../URL/URL.js",
- "../HTMLImports/build.json",
- "../CustomElements/build.json",
- "lang.js",
- "dom.js",
- "unresolved.js",
- "bc.js"
-]
diff --git a/src/WebComponents/build/boot.js b/src/WebComponents/build/boot.js
deleted file mode 100644
index 15103e5..0000000
--- a/src/WebComponents/build/boot.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function() {
-
- // Establish scope.
- window.WebComponents = window.WebComponents || {flags:{}};
-
- // loading script
- var file = 'webcomponents.js';
- var script = document.querySelector('script[src*="' + file + '"]');
-
- // Flags. Convert url arguments to flags
- var flags = {};
- if (!flags.noOpts) {
- // from url
- location.search.slice(1).split('&').forEach(function(option) {
- var parts = option.split('=');
- var match;
- if (parts[0] && (match = parts[0].match(/wc-(.+)/))) {
- flags[match[1]] = parts[1] || true;
- }
- });
- // from script
- if (script) {
- for (var i=0, a; (a=script.attributes[i]); i++) {
- if (a.name !== 'src') {
- flags[a.name] = a.value || true;
- }
- }
- }
- // log flags
- if (flags.log && flags.log.split) {
- var parts = flags.log.split(',');
- flags.log = {};
- parts.forEach(function(f) {
- flags.log[f] = true;
- });
- } else {
- flags.log = {};
- }
- }
-
- // Determine default settings.
- // If any of these flags match 'native', then force native ShadowDOM; any
- // other truthy value, or failure to detect native
- // ShadowDOM, results in polyfill
- flags.shadow = (flags.shadow || flags.shadowdom || flags.polyfill);
- if (flags.shadow === 'native') {
- flags.shadow = false;
- } else {
- flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
- }
-
- // forward flags
- if (flags.register) {
- window.CustomElements = window.CustomElements || {flags: {}};
- window.CustomElements.flags.register = flags.register;
- }
-
- // exports
- WebComponents.flags = flags;
-
-})();
diff --git a/src/WebComponents/build/else.js b/src/WebComponents/build/else.js
deleted file mode 100644
index dacd762..0000000
--- a/src/WebComponents/build/else.js
+++ /dev/null
@@ -1 +0,0 @@
-} else {
\ No newline at end of file
diff --git a/src/WebComponents/build/end-if.js b/src/WebComponents/build/end-if.js
deleted file mode 100644
index ff30235..0000000
--- a/src/WebComponents/build/end-if.js
+++ /dev/null
@@ -1 +0,0 @@
-}
\ No newline at end of file
diff --git a/src/WebComponents/build/if-poly.js b/src/WebComponents/build/if-poly.js
deleted file mode 100644
index 0c1b509..0000000
--- a/src/WebComponents/build/if-poly.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// select ShadowDOM impl
-if (WebComponents.flags.shadow) {
diff --git a/src/WebComponents/dom.js b/src/WebComponents/dom.js
deleted file mode 100644
index cb20fb7..0000000
--- a/src/WebComponents/dom.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
-
- 'use strict';
-
- // polyfill performance.now
-
- // Note: old Safari has performance, but not now().
- if (!(window.performance && window.performance.now)) {
- var start = Date.now();
- // only at millisecond precision
- window.performance = {now: function(){ return Date.now() - start; }};
- }
-
- // polyfill for requestAnimationFrame
-
- if (!window.requestAnimationFrame) {
- window.requestAnimationFrame = (function() {
- var nativeRaf = window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame;
-
- return nativeRaf ?
- function(callback) {
- return nativeRaf(function() {
- callback(performance.now());
- });
- } :
- function( callback ){
- return window.setTimeout(callback, 1000 / 60);
- };
- })();
- }
-
- if (!window.cancelAnimationFrame) {
- window.cancelAnimationFrame = (function() {
- return window.webkitCancelAnimationFrame ||
- window.mozCancelAnimationFrame ||
- function(id) {
- clearTimeout(id);
- };
- })();
- }
-
- // defaultPrevented is broken in IE.
- // https://connect.microsoft.com/IE/feedback/details/790389/event-defaultprevented-returns-false-after-preventdefault-was-called
- var workingDefaultPrevented = (function() {
- var e = document.createEvent('Event');
- e.initEvent('foo', true, true);
- e.preventDefault();
- return e.defaultPrevented;
- })();
-
- if (!workingDefaultPrevented) {
- var origPreventDefault = Event.prototype.preventDefault;
- Event.prototype.preventDefault = function() {
- if (!this.cancelable) {
- return;
- }
-
- origPreventDefault.call(this);
-
- Object.defineProperty(this, 'defaultPrevented', {
- get: function() {
- return true;
- },
- configurable: true
- });
- };
- }
-
- var isIE = /Trident/.test(navigator.userAgent);
-
- // CustomEvent constructor shim
- if (!window.CustomEvent || isIE && (typeof window.CustomEvent !== 'function')) {
- window.CustomEvent = function(inType, params) {
- params = params || {};
- var e = document.createEvent('CustomEvent');
- e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
- return e;
- };
- window.CustomEvent.prototype = window.Event.prototype;
- }
-
- // Event constructor shim
- if (!window.Event || isIE && (typeof window.Event !== 'function')) {
- var origEvent = window.Event;
- window.Event = function(inType, params) {
- params = params || {};
- var e = document.createEvent('Event');
- e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable));
- return e;
- };
- if (origEvent) {
- for (var i in origEvent) {
- window.Event[i] = origEvent[i];
- }
- }
- window.Event.prototype = origEvent.prototype;
- }
-
- if (!window.MouseEvent || isIE && (typeof window.MouseEvent !== 'function')) {
- var origMouseEvent = window.MouseEvent;
- window.MouseEvent = function(inType, params) {
- params = params || {};
- var e = document.createEvent('MouseEvent');
- e.initMouseEvent(inType,
- Boolean(params.bubbles), Boolean(params.cancelable),
- params.view || window, params.detail,
- params.screenX, params.screenY, params.clientX, params.clientY,
- params.ctrlKey, params.altKey, params.shiftKey, params.metaKey,
- params.button, params.relatedTarget);
- return e;
- };
- if (origMouseEvent) {
- for (var i in origMouseEvent) {
- window.MouseEvent[i] = origMouseEvent[i];
- }
- }
- window.MouseEvent.prototype = origMouseEvent.prototype;
- }
-
-})(window.WebComponents);
diff --git a/src/WebComponents/lang.js b/src/WebComponents/lang.js
deleted file mode 100644
index e56f8be..0000000
--- a/src/WebComponents/lang.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
-
- 'use strict';
-
- // Old versions of iOS do not have bind.
- if (!Function.prototype.bind) {
- Function.prototype.bind = function(scope) {
- var self = this;
- var args = Array.prototype.slice.call(arguments, 1);
- return function() {
- var args2 = args.slice();
- args2.push.apply(args2, arguments);
- return self.apply(scope, args2);
- };
- };
- }
-
- // ES6 stuff
- if (!Array.from) {
- Array.from = function (object) {
- return [].slice.call(object);
- };
- }
-
- if (!Object.assign) {
- var assign = function(target, source) {
- var n$ = Object.getOwnPropertyNames(source);
- for (var i=0, p; i < n$.length; i++) {
- p = n$[i];
- target[p] = source[p];
- }
- }
-
- Object.assign = function(target, sources) {
- var args = [].slice.call(arguments, 1);
- for (var i=0, s; i < args.length; i++) {
- s = args[i];
- if (s) {
- assign(target, s);
- }
- }
- return target;
- }
- }
-
-})(window.WebComponents);
diff --git a/src/WebComponents/shadowdom.js b/src/WebComponents/shadowdom.js
deleted file mode 100644
index adff0b4..0000000
--- a/src/WebComponents/shadowdom.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-(function(scope) {
- /**
- The ShadowDOM polyfill uses a wrapping strategy on dom elements. This is
- 99% transparent but there are a few nodes (e.g. document) that cannot be
- automatically wrapped. Therefore, rarely it's necessary to wrap nodes in
- user code. Here we're choosing to make convenient globals `wrap` and
- `unwrap` that can be used whether or not the polyfill is in use.
- */
- // convenient global
- if (window.ShadowDOMPolyfill) {
- window.wrap = ShadowDOMPolyfill.wrapIfNeeded;
- window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;
- } else {
- // so we can call wrap/unwrap without testing for ShadowDOMPolyfill
- window.wrap = window.unwrap = function(n) {
- return n;
- };
- }
-
-})(window.WebComponents);
diff --git a/src/WebComponents/build/boot-lite.js b/src/boot-lite.js
similarity index 90%
rename from src/WebComponents/build/boot-lite.js
rename to src/boot-lite.js
index c65f341..b039e47 100644
--- a/src/WebComponents/build/boot-lite.js
+++ b/src/boot-lite.js
@@ -48,12 +48,6 @@
}
}
- // forward flags
- if (flags.register) {
- window.CustomElements = window.CustomElements || {flags: {}};
- window.CustomElements.flags.register = flags.register;
- }
-
// exports
WebComponents.flags = flags;
diff --git a/src/build-lite.json b/src/build-lite.json
new file mode 100644
index 0000000..76b6778
--- /dev/null
+++ b/src/build-lite.json
@@ -0,0 +1,12 @@
+[
+ "boot-lite.js",
+ "../html-imports/html-imports.min.js",
+ "../../es6-promise/dist/es6-promise.auto.min.js",
+ "../../custom-elements/custom-elements.min.js",
+ "../../shadydom/shadydom.min.js",
+ "../../shadycss/shadycss.min.js",
+ "../../webcomponents-platform/webcomponents-platform.js",
+ "../../URL/url.js",
+ "../../template/template.js",
+ "unresolved.js"
+]
diff --git a/src/WebComponents/post-polyfill.js b/src/post-polyfill.js
similarity index 84%
rename from src/WebComponents/post-polyfill.js
rename to src/post-polyfill.js
index 1e59ec5..7f0c1bf 100644
--- a/src/WebComponents/post-polyfill.js
+++ b/src/post-polyfill.js
@@ -12,14 +12,6 @@
'use strict';
- window.CustomElements = {
- takeRecords: function() {
- if (customElements.flush) {
- customElements.flush();
- }
- }
- }
-
HTMLImports.whenReady(function() {
requestAnimationFrame(function() {
window.dispatchEvent(new CustomEvent('WebComponentsReady'));
diff --git a/src/WebComponents/pre-polyfill.js b/src/pre-polyfill.js
similarity index 100%
rename from src/WebComponents/pre-polyfill.js
rename to src/pre-polyfill.js
diff --git a/src/WebComponents/unresolved.js b/src/unresolved.js
similarity index 100%
rename from src/WebComponents/unresolved.js
rename to src/unresolved.js
diff --git a/tests/HTMLImports/html/HTMLImports.html b/tests/HTMLImports/html/HTMLImports.html
deleted file mode 100644
index e34768c..0000000
--- a/tests/HTMLImports/html/HTMLImports.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
- HTML Imports Test
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/HTMLImportsLoaded-native.html b/tests/HTMLImports/html/HTMLImportsLoaded-native.html
deleted file mode 100644
index 09af623..0000000
--- a/tests/HTMLImports/html/HTMLImportsLoaded-native.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
- HTMLImportsLoaded, native
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/base/load-base.html b/tests/HTMLImports/html/base/load-base.html
deleted file mode 100644
index b114c8a..0000000
--- a/tests/HTMLImports/html/base/load-base.html
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
- base load test
-
-
-
-
-
-
-
-
-
-
Test
-
Test
-
-
-
-
diff --git a/tests/HTMLImports/html/csp.html b/tests/HTMLImports/html/csp.html
deleted file mode 100644
index d0f6c33..0000000
--- a/tests/HTMLImports/html/csp.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- parser Test
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/csp.js b/tests/HTMLImports/html/csp.js
deleted file mode 100644
index 159e0c1..0000000
--- a/tests/HTMLImports/html/csp.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-test('imported scripts loaded under CSP', function() {
- chai.assert.ok(window.externalScriptParsed1, 'externalScriptParsed1');
- chai.assert.ok(window.externalScriptParsed2, 'externalScriptParsed2');
-});
diff --git a/tests/HTMLImports/html/currentScript.html b/tests/HTMLImports/html/currentScript.html
deleted file mode 100644
index 95405a3..0000000
--- a/tests/HTMLImports/html/currentScript.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
- _currentScript Test
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/customevent-detail.html b/tests/HTMLImports/html/customevent-detail.html
deleted file mode 100644
index a88f37b..0000000
--- a/tests/HTMLImports/html/customevent-detail.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
- CustomEvent detail test
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/dedupe.html b/tests/HTMLImports/html/dedupe.html
deleted file mode 100644
index e452b60..0000000
--- a/tests/HTMLImports/html/dedupe.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
- HTML dedupe Test
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/dynamic-all-imports-detail.html b/tests/HTMLImports/html/dynamic-all-imports-detail.html
deleted file mode 100644
index 603e7cf..0000000
--- a/tests/HTMLImports/html/dynamic-all-imports-detail.html
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
- HTML Imports Dynamic
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/dynamic-elements.html b/tests/HTMLImports/html/dynamic-elements.html
deleted file mode 100644
index 3ed039a..0000000
--- a/tests/HTMLImports/html/dynamic-elements.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
- HTML Imports Dynamic Elements
-
-
-
-
-
-
red?
-
-
-
-
diff --git a/tests/HTMLImports/html/dynamic-errors-detail.html b/tests/HTMLImports/html/dynamic-errors-detail.html
deleted file mode 100644
index d93a0e6..0000000
--- a/tests/HTMLImports/html/dynamic-errors-detail.html
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- HTML Imports Dynamic
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/dynamic.html b/tests/HTMLImports/html/dynamic.html
deleted file mode 100644
index c27a5bc..0000000
--- a/tests/HTMLImports/html/dynamic.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- HTML Imports Dynamic
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/imports/abs.html b/tests/HTMLImports/html/imports/abs.html
deleted file mode 100644
index 7e6fca8..0000000
--- a/tests/HTMLImports/html/imports/abs.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/dedupe.html b/tests/HTMLImports/html/imports/dedupe.html
deleted file mode 100644
index 109b9bd..0000000
--- a/tests/HTMLImports/html/imports/dedupe.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
diff --git a/tests/HTMLImports/html/imports/dynamic-elements-import.html b/tests/HTMLImports/html/imports/dynamic-elements-import.html
deleted file mode 100644
index cce128a..0000000
--- a/tests/HTMLImports/html/imports/dynamic-elements-import.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
diff --git a/tests/HTMLImports/html/imports/encoding-import.html b/tests/HTMLImports/html/imports/encoding-import.html
deleted file mode 100644
index f71994a..0000000
--- a/tests/HTMLImports/html/imports/encoding-import.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
diff --git a/tests/HTMLImports/html/imports/external-script.js b/tests/HTMLImports/html/imports/external-script.js
deleted file mode 100644
index cf69594..0000000
--- a/tests/HTMLImports/html/imports/external-script.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-window.externalScriptParsed = new Date().getTime();
diff --git a/tests/HTMLImports/html/imports/google.png b/tests/HTMLImports/html/imports/google.png
deleted file mode 100644
index 1974f31..0000000
Binary files a/tests/HTMLImports/html/imports/google.png and /dev/null differ
diff --git a/tests/HTMLImports/html/imports/import-1-1.html b/tests/HTMLImports/html/imports/import-1-1.html
deleted file mode 100644
index a4db731..0000000
--- a/tests/HTMLImports/html/imports/import-1-1.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/import-1-2.html b/tests/HTMLImports/html/imports/import-1-2.html
deleted file mode 100644
index 0dc4dc2..0000000
--- a/tests/HTMLImports/html/imports/import-1-2.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/import-1-3.html b/tests/HTMLImports/html/imports/import-1-3.html
deleted file mode 100644
index 3c6c9a1..0000000
--- a/tests/HTMLImports/html/imports/import-1-3.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/import-1.html b/tests/HTMLImports/html/imports/import-1.html
deleted file mode 100644
index fce66dc..0000000
--- a/tests/HTMLImports/html/imports/import-1.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/load-1.html b/tests/HTMLImports/html/imports/load-1.html
deleted file mode 100644
index 40c7a81..0000000
--- a/tests/HTMLImports/html/imports/load-1.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/load-2.html b/tests/HTMLImports/html/imports/load-2.html
deleted file mode 100644
index a3cb3e3..0000000
--- a/tests/HTMLImports/html/imports/load-2.html
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
diff --git a/tests/HTMLImports/html/imports/load-a.html b/tests/HTMLImports/html/imports/load-a.html
deleted file mode 100644
index b79070d..0000000
--- a/tests/HTMLImports/html/imports/load-a.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/load-b.html b/tests/HTMLImports/html/imports/load-b.html
deleted file mode 100644
index c616fd0..0000000
--- a/tests/HTMLImports/html/imports/load-b.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/load-c.html b/tests/HTMLImports/html/imports/load-c.html
deleted file mode 100644
index 2a8f2ac..0000000
--- a/tests/HTMLImports/html/imports/load-c.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/load-d.html b/tests/HTMLImports/html/imports/load-d.html
deleted file mode 100644
index 8caa784..0000000
--- a/tests/HTMLImports/html/imports/load-d.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/parsed-import-1.html b/tests/HTMLImports/html/imports/parsed-import-1.html
deleted file mode 100644
index 335348f..0000000
--- a/tests/HTMLImports/html/imports/parsed-import-1.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
diff --git a/tests/HTMLImports/html/imports/parsed-import-2.html b/tests/HTMLImports/html/imports/parsed-import-2.html
deleted file mode 100644
index 5dad021..0000000
--- a/tests/HTMLImports/html/imports/parsed-import-2.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
diff --git a/tests/HTMLImports/html/imports/sheet1.css b/tests/HTMLImports/html/imports/sheet1.css
deleted file mode 100644
index f68768c..0000000
--- a/tests/HTMLImports/html/imports/sheet1.css
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.red {
- background-color: red;
-}
-
-.overridden {
- background-color: green;
-}
diff --git a/tests/HTMLImports/html/imports/sheet2.css b/tests/HTMLImports/html/imports/sheet2.css
deleted file mode 100644
index a184a88..0000000
--- a/tests/HTMLImports/html/imports/sheet2.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.blue {
- background-color: blue;
-}
diff --git a/tests/HTMLImports/html/imports/sheet3.css b/tests/HTMLImports/html/imports/sheet3.css
deleted file mode 100644
index 723cf48..0000000
--- a/tests/HTMLImports/html/imports/sheet3.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.orange {
- background-color: orange;
-}
diff --git a/tests/HTMLImports/html/imports/sheet4.css b/tests/HTMLImports/html/imports/sheet4.css
deleted file mode 100644
index acc3a3b..0000000
--- a/tests/HTMLImports/html/imports/sheet4.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.link-typed {
- background-color: navy;
-}
diff --git a/tests/HTMLImports/html/imports/style-elements-import.html b/tests/HTMLImports/html/imports/style-elements-import.html
deleted file mode 100644
index e6370f5..0000000
--- a/tests/HTMLImports/html/imports/style-elements-import.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/style-links-import.html b/tests/HTMLImports/html/imports/style-links-import.html
deleted file mode 100644
index 6c1fbfd..0000000
--- a/tests/HTMLImports/html/imports/style-links-import.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/imports/style-paths-import.html b/tests/HTMLImports/html/imports/style-paths-import.html
deleted file mode 100644
index fb09c84..0000000
--- a/tests/HTMLImports/html/imports/style-paths-import.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/imports/styles.css b/tests/HTMLImports/html/imports/styles.css
deleted file mode 100644
index db41ba8..0000000
--- a/tests/HTMLImports/html/imports/styles.css
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-/*
- Document : styles
- Created on : Apr 9, 2013, 5:55:32 PM
- Author : sjmiles
- Description:
- Purpose of the stylesheet follows.
-*/
-root {
- display: block;
-}
-
diff --git a/tests/HTMLImports/html/imports/template-import.html b/tests/HTMLImports/html/imports/template-import.html
deleted file mode 100644
index 80181cd..0000000
--- a/tests/HTMLImports/html/imports/template-import.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/HTMLImports/html/load-404.html b/tests/HTMLImports/html/load-404.html
deleted file mode 100644
index b475da8..0000000
--- a/tests/HTMLImports/html/load-404.html
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
- load ready 404 test
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/load-loop.html b/tests/HTMLImports/html/load-loop.html
deleted file mode 100644
index e48d214..0000000
--- a/tests/HTMLImports/html/load-loop.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- load loop Test
-
-
-
-
-
-
-
-
-
diff --git a/tests/HTMLImports/html/load.html b/tests/HTMLImports/html/load.html
deleted file mode 100644
index f74f50b..0000000
--- a/tests/HTMLImports/html/load.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
- load event Test
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowCSS/html/combinators-import.css b/tests/ShadowCSS/html/combinators-import.css
deleted file mode 100644
index 044b7e9..0000000
--- a/tests/ShadowCSS/html/combinators-import.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-x-foo ^ .foo2 {
- background: green;
-}
diff --git a/tests/ShadowCSS/html/combinators-import.html b/tests/ShadowCSS/html/combinators-import.html
deleted file mode 100644
index 97da1d6..0000000
--- a/tests/ShadowCSS/html/combinators-import.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/ShadowCSS/html/combinators-shadow-import.css b/tests/ShadowCSS/html/combinators-shadow-import.css
deleted file mode 100644
index 523d9ee..0000000
--- a/tests/ShadowCSS/html/combinators-shadow-import.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-x-foo::shadow .foo2 {
- background: green;
-}
diff --git a/tests/ShadowCSS/html/combinators-shadow-import.html b/tests/ShadowCSS/html/combinators-shadow-import.html
deleted file mode 100644
index e769754..0000000
--- a/tests/ShadowCSS/html/combinators-shadow-import.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/ShadowCSS/html/combinators-shadow.css b/tests/ShadowCSS/html/combinators-shadow.css
deleted file mode 100644
index 99531c1..0000000
--- a/tests/ShadowCSS/html/combinators-shadow.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-body /deep/ x-zot::shadow .zot-inner {
- background: blue;
-}
diff --git a/tests/ShadowCSS/html/combinators-shadow.html b/tests/ShadowCSS/html/combinators-shadow.html
deleted file mode 100644
index 5642e85..0000000
--- a/tests/ShadowCSS/html/combinators-shadow.html
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
- Using combinators styling
-
-
-
-
-
-
-
-
-
-
-
-
-
orange
-
green
-
-
-
-
-
Bar
-
Noogy
-
-
-
-
-
Zot
-
Zot
-
inner
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowCSS/html/combinators.css b/tests/ShadowCSS/html/combinators.css
deleted file mode 100644
index 6927db0..0000000
--- a/tests/ShadowCSS/html/combinators.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-body ^^ x-zot ^ .zot-inner {
- background: blue;
-}
diff --git a/tests/ShadowCSS/html/combinators.html b/tests/ShadowCSS/html/combinators.html
deleted file mode 100644
index a14330d..0000000
--- a/tests/ShadowCSS/html/combinators.html
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
-
-
- Using combinators styling
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowCSS/html/imports/sheet1.css b/tests/ShadowCSS/html/imports/sheet1.css
deleted file mode 100644
index 98f59bb..0000000
--- a/tests/ShadowCSS/html/imports/sheet1.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.red {
- background: red;
-}
diff --git a/tests/ShadowCSS/html/imports/sheet2.css b/tests/ShadowCSS/html/imports/sheet2.css
deleted file mode 100644
index db55f4c..0000000
--- a/tests/ShadowCSS/html/imports/sheet2.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-.blue {
- background: blue;
-}
diff --git a/tests/ShadowCSS/html/imports/style-import-base-tag.css b/tests/ShadowCSS/html/imports/style-import-base-tag.css
deleted file mode 100644
index 890db85..0000000
--- a/tests/ShadowCSS/html/imports/style-import-base-tag.css
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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 "../imports/sheet1.css";
diff --git a/tests/ShadowCSS/html/imports/style-import.html b/tests/ShadowCSS/html/imports/style-import.html
deleted file mode 100644
index 3cce469..0000000
--- a/tests/ShadowCSS/html/imports/style-import.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
diff --git a/tests/ShadowCSS/html/polyfill-directive.html b/tests/ShadowCSS/html/polyfill-directive.html
deleted file mode 100644
index 0277258..0000000
--- a/tests/ShadowCSS/html/polyfill-directive.html
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
- polyfill directive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowCSS/html/register.js b/tests/ShadowCSS/html/register.js
deleted file mode 100644
index a122ad8..0000000
--- a/tests/ShadowCSS/html/register.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-(function(scope) {
-
- var extendsRegistry = {};
-
- function register(name, extnds, proto, templates) {
- extendsRegistry[name] = extnds;
- var typeExtension = extnds && extnds.indexOf('-') < 0;
- var names = calcExtendsNames(name);
- if (window.ShadowDOMPolyfill) {
- shim(templates, names);
- }
-
- var config = {
- prototype: Object.create(proto, {
- createdCallback: {
- value: function() {
- for (var i=0, n; i < names.length; i++) {
- n = names[i];
- var template = templateForName(n);
- if (template) {
- this.createShadowRoot().appendChild(document.importNode(template.content, true));
- }
- }
- }
- }
- })
- };
- if (typeExtension) {
- config.extends = extnds;
- }
- var ctor = document.registerElement(name, config);
- return ctor;
- }
-
- function calcExtendsNames(name) {
- var names = [], n = name;
- while (n) {
- names.push(n);
- n = extendsRegistry[n];
- }
- return names.reverse();
- }
-
- function templateForName(name) {
- return document.querySelector('#' + name);
- }
-
- function shim(templates, names) {
- var n = names[names.length-1];
- var template = templateForName(n);
- WebComponents.ShadowCSS.shimStyling(template ? template.content : null, n, extendsRegistry[n]);
- }
-
- scope.register = register;
-
-})(window);
-
diff --git a/tests/ShadowCSS/html/style-import-base-tag.html b/tests/ShadowCSS/html/style-import-base-tag.html
deleted file mode 100644
index 581e0fd..0000000
--- a/tests/ShadowCSS/html/style-import-base-tag.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- Imports style loading with base tag
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/document-body-inner-html.html b/tests/ShadowDOM/html/document-body-inner-html.html
deleted file mode 100644
index eb2c17c..0000000
--- a/tests/ShadowDOM/html/document-body-inner-html.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/document-body-shadow-root.html b/tests/ShadowDOM/html/document-body-shadow-root.html
deleted file mode 100644
index 8cb1961..0000000
--- a/tests/ShadowDOM/html/document-body-shadow-root.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/document-write.html b/tests/ShadowDOM/html/document-write.html
deleted file mode 100644
index 6c8560f..0000000
--- a/tests/ShadowDOM/html/document-write.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/full-suite.html b/tests/ShadowDOM/html/full-suite.html
deleted file mode 100644
index ecf6039..0000000
--- a/tests/ShadowDOM/html/full-suite.html
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-Full ShadowDOM suite
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/head-then-body.html b/tests/ShadowDOM/html/head-then-body.html
deleted file mode 100644
index 5b9ca86..0000000
--- a/tests/ShadowDOM/html/head-then-body.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/on-load-test.html b/tests/ShadowDOM/html/on-load-test.html
deleted file mode 100644
index e1a8962..0000000
--- a/tests/ShadowDOM/html/on-load-test.html
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
diff --git a/tests/ShadowDOM/html/on-unload-test.html b/tests/ShadowDOM/html/on-unload-test.html
deleted file mode 100644
index 7ae7807..0000000
--- a/tests/ShadowDOM/html/on-unload-test.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
diff --git a/tests/ShadowDOM/js/ChildNodeInterface.js b/tests/ShadowDOM/js/ChildNodeInterface.js
deleted file mode 100644
index 1fac5b6..0000000
--- a/tests/ShadowDOM/js/ChildNodeInterface.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('ChildNodeInterface', function() {
-
- function getTree() {
- var tree = {};
- var div = tree.div = document.createElement('div');
- div.innerHTML = 'ace';
- var a = tree.a = div.firstChild;
- var b = tree.b = a.nextSibling;
- var c = tree.c = b.nextSibling;
- var d = tree.d = c.nextSibling;
- var e = tree.e = d.nextSibling;
-
- var sr = tree.sr = div.createShadowRoot();
- sr.innerHTML = 'fhik';
- var f = tree.f = sr.firstChild;
- var g = tree.g = f.nextSibling;
- var h = tree.h = g.nextSibling;
- var content = tree.content = h.nextSibling;
- var i = tree.i = content.nextSibling;
- var j = tree.j = i.nextSibling;
- var k = tree.k = j.nextSibling;
-
- div.offsetHeight; // trigger rendering
-
- return tree;
- }
-
- test('nextElementSibling', function() {
- var tree = getTree();
-
- assert.equal(tree.b.nextElementSibling, tree.d);
- assert.equal(tree.d.nextElementSibling, null);
- assert.equal(tree.g.nextElementSibling, tree.content);
- assert.equal(tree.content.nextElementSibling, tree.j);
- assert.equal(tree.j.nextElementSibling, null);
- });
-
- test('previousElementSibling', function() {
- var tree = getTree();
-
- assert.equal(tree.b.previousElementSibling, null);
- assert.equal(tree.d.previousElementSibling, tree.b);
- assert.equal(tree.g.previousElementSibling, null);
- assert.equal(tree.content.previousElementSibling, tree.g);
- assert.equal(tree.j.previousElementSibling, tree.content);
- });
-
- test('remove', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var a = div.firstChild;
- a.remove();
- assert.equal(div.firstChild, null);
- assert.equal(a.parentNode, null);
-
- // no op.
- div.remove();
- });
-
-});
diff --git a/tests/ShadowDOM/js/Comment.js b/tests/ShadowDOM/js/Comment.js
deleted file mode 100644
index faccb81..0000000
--- a/tests/ShadowDOM/js/Comment.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Comment', function() {
-
- test('instanceof', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- assert.instanceOf(div.firstChild, Comment);
- });
-
- test('instanceof', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- assert.equal(Comment, div.firstChild.constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/DOMTokenList.js b/tests/ShadowDOM/js/DOMTokenList.js
deleted file mode 100644
index 411b270..0000000
--- a/tests/ShadowDOM/js/DOMTokenList.js
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('DOMTokenList', function() {
- if (!window.DOMTokenList) {
- test('classList returns undefined if not supported', function() {
- var div = document.createElement('div');
- assert.isUndefined(div.classList);
- });
- return;
- }
-
- test('instanceof', function() {
- var div = document.createElement('div');
- assert.instanceOf(div.classList, DOMTokenList);
- });
-
- test('constructor', function() {
- var div = document.createElement('div');
- assert.equal(DOMTokenList, div.classList.constructor);
- });
-
- test('identity', function() {
- var div = document.createElement('div');
- assert.equal(div.classList, div.classList);
- });
-
- test('length', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- assert.equal(classList.length, 0);
- div.className = 'a';
- assert.equal(classList.length, 1);
- div.className = 'a b';
- assert.equal(classList.length, 2);
- div.className = 'a b a';
- assert.equal(classList.length, 3);
- });
-
- test('item', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- assert.isNull(classList.item(0));
- div.className = 'a';
- assert.equal(classList.item(0), 'a');
- assert.isNull(classList.item(1));
- div.className = 'a b';
- assert.equal(classList.item(0), 'a');
- assert.equal(classList.item(1), 'b');
- assert.isNull(classList.item(2));
- div.className = 'a b a';
- assert.equal(classList.item(0), 'a');
- assert.equal(classList.item(1), 'b');
- assert.equal(classList.item(2), 'a');
- assert.isNull(classList.item(3));
- });
-
- test('contains', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- assert.isFalse(classList.contains('a'));
- div.className = 'a';
- assert.isTrue(classList.contains('a'));
- div.className = 'a b';
- assert.isTrue(classList.contains('a'));
- assert.isTrue(classList.contains('b'));
- });
-
- test('add', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- classList.add('a');
- assert.equal(div.className, 'a');
- classList.add('b');
- assert.equal(div.className, 'a b');
- classList.add('a');
- assert.equal(div.className, 'a b');
- });
-
- test('remove', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- div.className = 'a b';
- classList.remove('a');
- assert.equal(div.className, 'b');
- classList.remove('a');
- assert.equal(div.className, 'b');
- classList.remove('b');
- assert.equal(div.className, '');
- });
-
- test('toggle', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- div.className = 'a b';
- classList.toggle('a');
- assert.equal(div.className, 'b');
- classList.toggle('a');
- assert.equal(div.className, 'b a');
- classList.toggle('b');
- assert.equal(div.className, 'a');
- });
-
- test('toString', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- div.className = 'a';
- assert.equal(classList.toString(), 'a');
- div.className = 'b a';
- assert.equal(classList.toString(), 'b a');
- });
-
- test('index', function() {
- var div = document.createElement('div');
- var classList = div.classList;
- classList.add('a');
- classList.add('b');
- assert.equal(classList[0], 'a');
- assert.equal(classList[1], 'b');
- });
-});
diff --git a/tests/ShadowDOM/js/Document.js b/tests/ShadowDOM/js/Document.js
deleted file mode 100644
index 0cdebe9..0000000
--- a/tests/ShadowDOM/js/Document.js
+++ /dev/null
@@ -1,707 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Document', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- var div;
- teardown(function() {
- if (div) {
- if (div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- }
- });
-
- function skipTest () {}
-
- test('Ensure Document has ParentNodeInterface', function() {
- var doc = wrap(document).implementation.createHTMLDocument('');
- assert.equal(doc.firstElementChild.tagName, 'HTML');
- assert.equal(doc.lastElementChild.tagName, 'HTML');
-
- var doc2 = document.implementation.createHTMLDocument('');
- assert.equal(doc2.firstElementChild.tagName, 'HTML');
- assert.equal(doc2.lastElementChild.tagName, 'HTML');
- });
-
- test('Create XHTML Document', function() {
- var docType = wrap(document).implementation.createDocumentType('html', '-//W3C//DTD XHTML 1.0 Transitional//EN',
- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
- var doc = wrap(document).implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', docType);
- assert(doc);
- });
-
- test('document.documentElement', function() {
- var doc = wrap(document);
- assert.equal(doc.documentElement.ownerDocument, doc);
- assert.equal(doc.documentElement.tagName, 'HTML');
- });
-
- test('document.body', function() {
- var doc = wrap(document);
- assert.equal(doc.body.ownerDocument, doc);
- assert.equal(doc.body.tagName, 'BODY');
- assert.equal(doc.body.parentNode, doc.documentElement);
- });
-
- test('document.head', function() {
- var doc = wrap(document);
- assert.equal(doc.head.ownerDocument, doc);
- assert.equal(doc.head.tagName, 'HEAD');
- assert.equal(doc.head.parentNode, doc.documentElement);
- });
-
- test('document.matches', function() {
- var doc = wrap(document);
- assert.isTrue(doc.matches === undefined);
- });
-
- test('getElementsByTagName', function() {
- var elements = document.getElementsByTagName('body');
- assert.isTrue(elements instanceof HTMLCollection);
- assert.equal(elements.length, 1);
- assert.isTrue(elements[0] instanceof HTMLElement);
-
- var doc = wrap(document);
- assert.equal(doc.body, elements[0]);
- assert.equal(doc.body, elements.item(0));
-
- var elements2 = doc.getElementsByTagName('body');
- assert.isTrue(elements2 instanceof HTMLCollection);
- assert.equal(elements2.length, 1);
- assert.isTrue(elements2[0] instanceof HTMLElement);
- assert.equal(doc.body, elements2[0]);
- assert.equal(doc.body, elements2.item(0));
- });
-
- skipTest('getElementsByTagName', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var aa3 = sr.firstChild;
- var aa4 = sr.lastChild;
-
- div.offsetHeight;
-
- var elements = document.getElementsByTagName('aa');
- assert.equal(elements.length, 2);
- assert.equal(elements[0], aa1);
- assert.equal(elements[1], aa2);
-
- var elements = sr.getElementsByTagName('aa');
- assert.equal(elements.length, 2);
- assert.equal(elements[0], aa3);
- assert.equal(elements[1], aa4);
-
- var z = document.getElementsByTagName('z');
- assert.equal(z.length, 0);
- });
-
- test('getElementsByTagNameNS', function() {
- var div = document.createElement('div');
- var nsOne = 'http://one.com';
- var nsTwo = 'http://two.com';
- var aOne = div.appendChild(document.createElementNS(nsOne, 'a'));
- var aTwo = div.appendChild(document.createElementNS(nsTwo, 'a'));
- var aNull = div.appendChild(document.createElementNS(null, 'a'));
- var bOne = div.appendChild(document.createElementNS(nsOne, 'b'));
- var bTwo = div.appendChild(document.createElementNS(nsTwo, 'b'));
- var bNull = div.appendChild(document.createElementNS(null, 'b'));
-
- var all = div.getElementsByTagNameNS(nsOne, 'a');
- assert.equal(all.length, 1);
- assert.equal(all[0], aOne);
-
- var all = div.getElementsByTagNameNS(nsTwo, 'a');
- assert.equal(all.length, 1);
- assert.equal(all[0], aTwo);
-
- var all = div.getElementsByTagNameNS(null, 'a');
- assert.equal(all.length, 1);
- assert.equal(all[0], aNull);
-
- var all = div.getElementsByTagNameNS('', 'a');
- assert.equal(all.length, 1);
- assert.equal(all[0], aNull);
-
- var all = div.getElementsByTagNameNS('*', 'a');
- assert.equal(all.length, 3);
- assert.equal(all[0], aOne);
- assert.equal(all[1], aTwo);
- assert.equal(all[2], aNull);
-
- var all = div.getElementsByTagNameNS(nsOne, '*');
- assert.equal(all.length, 2);
- assert.equal(all[0], aOne);
- assert.equal(all[1], bOne);
-
- var all = div.getElementsByTagNameNS('*', '*');
- assert.equal(all.length, 6);
- assert.equal(all[0], aOne);
- assert.equal(all[1], aTwo);
- assert.equal(all[2], aNull);
- assert.equal(all[3], bOne);
- assert.equal(all[4], bTwo);
- assert.equal(all[5], bNull);
-
- var all = div.getElementsByTagNameNS('*', 'A');
- assert.equal(all.length, 0);
- });
-
- test('querySelectorAll', function() {
- var elements = document.querySelectorAll('body');
- assert.isTrue(elements instanceof NodeList);
- assert.equal(elements.length, 1);
- assert.isTrue(elements[0] instanceof HTMLElement);
-
- var doc = wrap(document);
- assert.equal(doc.body, elements[0]);
-
- var elements2 = doc.querySelectorAll('body');
- assert.isTrue(elements2 instanceof NodeList);
- assert.equal(elements2.length, 1);
- assert.isTrue(elements2[0] instanceof HTMLElement);
- assert.equal(doc.body, elements2[0]);
- });
-
- skipTest('querySelectorAll', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var aa3 = sr.firstChild;
- var aa4 = sr.lastChild;
-
- div.offsetHeight;
-
- var elements = document.querySelectorAll('aa');
- assert.equal(elements.length, 2);
- assert.equal(elements[0], aa1);
- assert.equal(elements[1], aa2);
-
- var elements = sr.querySelectorAll('aa');
- assert.equal(elements.length, 2);
- assert.equal(elements[0], aa3);
- assert.equal(elements[1], aa4);
-
- var z = document.querySelectorAll('z');
- assert.equal(z.length, 0);
- });
-
- test('querySelector', function() {
- var z = document.querySelector('z');
- assert.equal(z, null);
- });
-
- test('querySelector deep', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- assert.equal(aa1, document.querySelector('div /deep/ aa'));
- assert.equal(bb, document.querySelector('div /deep/ bb'));
-
- assert.equal(aa1, document.querySelector('div >>> aa'));
- assert.equal(bb, document.querySelector('div >>> bb'));
- });
-
- test('querySelectorAll deep', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- ['div /deep/ aa', 'div >>> aa'].forEach(function(selector) {
- var list = div.querySelectorAll(selector);
- assert.equal(2, list.length);
- assert.equal(aa1, list[0]);
- assert.equal(aa2, list[1]);
- });
-
- ['div /deep/ bb', 'div >>> bb'].forEach(function(selector) {
- var list = div.querySelectorAll(selector);
- assert.equal(1, list.length);
- assert.equal(bb, list[0]);
- });
- });
-
- test('addEventListener', function() {
- var calls = 0;
- var doc = wrap(document);
- document.addEventListener('click', function f(e) {
- calls++;
- assert.equal(this, doc);
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, this);
- document.removeEventListener('click', f);
- });
- doc.addEventListener('click', function f(e) {
- calls++;
- assert.equal(this, doc);
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, this);
- doc.removeEventListener('click', f);
- });
-
- document.body.click();
- assert.equal(2, calls);
-
- document.body.click();
- assert.equal(2, calls);
- });
-
- test('adoptNode', function() {
- var doc = wrap(document);
- var doc2 = doc.implementation.createHTMLDocument('');
- var div = doc2.createElement('div');
- assert.equal(div.ownerDocument, doc2);
-
- var div2 = document.adoptNode(div);
- assert.equal(div, div2);
- assert.equal(div.ownerDocument, doc);
-
- var div3 = doc2.adoptNode(div);
- assert.equal(div, div3);
- assert.equal(div.ownerDocument, doc2);
- });
-
- test('adoptNode with shadowRoot', function() {
- var doc = wrap(document);
- var doc2 = doc.implementation.createHTMLDocument('');
- var div = doc2.createElement('div');
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
-
- var sr2 = div.createShadowRoot();
- sr2.innerHTML = '';
- var b = sr2.firstChild;
-
- var sr3 = a.createShadowRoot();
- sr3.innerHTML = '';
- var c = sr3.firstChild;
-
- assert.equal(div.ownerDocument, doc2);
- assert.equal(sr.ownerDocument, doc2);
- assert.equal(sr2.ownerDocument, doc2);
- assert.equal(sr3.ownerDocument, doc2);
- assert.equal(a.ownerDocument, doc2);
- assert.equal(b.ownerDocument, doc2);
- assert.equal(c.ownerDocument, doc2);
-
- doc.adoptNode(div);
-
- assert.equal(div.ownerDocument, doc);
- assert.equal(sr.ownerDocument, doc);
- assert.equal(sr2.ownerDocument, doc);
- assert.equal(sr3.ownerDocument, doc);
- assert.equal(a.ownerDocument, doc);
- assert.equal(b.ownerDocument, doc);
- assert.equal(c.ownerDocument, doc);
- });
-
- test('importNode', function() {
- var doc = wrap(document);
- var doc2 = doc.implementation.createHTMLDocument('');
- var div = doc2.createElement('div');
- div.innerHTML = 'test';
- assert.equal(div.ownerDocument, doc2);
-
- var div2 = document.importNode(div, true);
- assert.equal(div.innerHTML, div2.innerHTML);
- assert.equal(div2.ownerDocument, doc);
-
- var div3 = doc2.importNode(div2);
- assert.equal(div3.innerHTML, '');
- assert.equal(div3.ownerDocument, doc2);
- });
-
- test('importNode with shadow root', function() {
- var doc = wrap(document);
- var doc2 = doc.implementation.createHTMLDocument('');
- var div = doc2.createElement('div');
- div.textContent = 'test';
- var sr = div.createShadowRoot();
- sr.textContent = 'shadow root';
-
- div.offsetHeight;
-
- assert.equal(div.ownerDocument, doc2);
-
- var div2 = document.importNode(div, true);
- assert.equal(div.innerHTML, div2.innerHTML);
- assert.equal(div2.ownerDocument, doc);
-
- var div3 = doc2.importNode(div2);
- assert.equal(div3.innerHTML, '');
- assert.equal(div3.ownerDocument, doc2);
- });
-
- test('elementFromPoint', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.style.cssText = 'position: fixed; background: green; ' +
- 'width: 10px; height: 10px; top: 0; left: 0;';
-
- assert.equal(document.elementFromPoint(5, 5), div);
-
- var doc = wrap(document);
- assert.equal(doc.elementFromPoint(5, 5), div);
- });
-
- test('elementFromPoint in shadow', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.style.cssText = 'position: fixed; background: red; ' +
- 'width: 10px; height: 10px; top: 0; left: 0;';
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
- a.style.cssText = 'position: absolute; width: 100%; height: 100%; ' +
- 'background: green';
-
- assert.equal(document.elementFromPoint(5, 5), div);
-
- var doc = wrap(document);
- assert.equal(doc.elementFromPoint(5, 5), div);
- });
-
- test('elementFromPoint null', function() {
- assert.isNull(document.elementFromPoint(-9999, -9999));
-
- var doc = wrap(document);
- assert.isNull(doc.elementFromPoint(-9999, -9999));
- });
-
- test('document.contains', function() {
- assert.isTrue(document.contains(document.body));
- assert.isTrue(document.contains(document.querySelector('body')));
-
- assert.isTrue(document.contains(document.head));
- assert.isTrue(document.contains(document.querySelector('head')));
-
- assert.isTrue(document.contains(document.documentElement));
- assert.isTrue(document.contains(document.querySelector('html')));
- });
-
- test('document.registerElement', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- var aPrototype = Object.create(HTMLElement.prototype);
- aPrototype.getName = function() {
- return 'a';
- };
-
- var A = document.registerElement('x-a', {prototype: aPrototype});
-
- var a1 = document.createElement('x-a');
- assert.equal('x-a', a1.localName);
- assert.equal(Object.getPrototypeOf(a1), aPrototype);
- assert.instanceOf(a1, A);
- assert.instanceOf(a1, HTMLElement);
- assert.equal(a1.getName(), 'a');
-
- var a2 = new A();
- assert.equal('x-a', a2.localName);
- assert.equal(Object.getPrototypeOf(a2), aPrototype);
- assert.instanceOf(a2, A);
- assert.instanceOf(a2, HTMLElement);
- assert.equal(a2.getName(), 'a');
-
- //////////////////////////////////////////////////////////////////////
-
- var bPrototype = Object.create(A.prototype);
- bPrototype.getName = function() {
- return 'b';
- };
-
- var B = document.registerElement('x-b', {prototype: bPrototype});
-
- var b1 = document.createElement('x-b');
- assert.equal('x-b', b1.localName);
- assert.equal(Object.getPrototypeOf(b1), bPrototype);
- assert.instanceOf(b1, B);
- assert.instanceOf(b1, A);
- assert.instanceOf(b1, HTMLElement);
- assert.equal(b1.getName(), 'b');
-
- var b2 = new B();
- assert.equal('x-b', b2.localName);
- assert.equal(Object.getPrototypeOf(b2), bPrototype);
- assert.instanceOf(b2, B);
- assert.instanceOf(b2, A);
- assert.instanceOf(b2, HTMLElement);
- assert.equal(b2.getName(), 'b');
- });
-
- test('document.registerElement type extension', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- var aPrototype = Object.create(HTMLSpanElement.prototype);
- aPrototype.getName = function() {
- return 'a';
- };
-
- var A = document.registerElement('x-a-span',
- {prototype: aPrototype, extends: 'span'});
-
- var a1 = document.createElement('span', 'x-a-span');
- assert.equal('span', a1.localName);
- assert.equal('', a1.outerHTML);
- assert.equal(Object.getPrototypeOf(a1), aPrototype);
- assert.instanceOf(a1, A);
- assert.instanceOf(a1, HTMLSpanElement);
- assert.equal(a1.getName(), 'a');
-
- var a2 = new A();
- assert.equal('span', a2.localName);
- assert.equal('', a2.outerHTML);
- assert.equal(Object.getPrototypeOf(a2), aPrototype);
- assert.instanceOf(a2, A);
- assert.instanceOf(a2, HTMLSpanElement);
- assert.equal(a2.getName(), 'a');
- });
-
- test('document.registerElement deeper', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- function C() {}
- C.prototype = {
- __proto__: HTMLElement.prototype
- };
-
- function B() {}
- B.prototype = {
- __proto__: C.prototype
- };
-
- function A() {}
- A.prototype = {
- __proto__: B.prototype
- };
-
- A = document.registerElement('x-a5', A);
-
- var a1 = document.createElement('x-a5');
- assert.equal('x-a5', a1.localName);
- assert.equal(a1.__proto__, A.prototype);
- assert.equal(a1.__proto__.__proto__, B.prototype);
- assert.equal(a1.__proto__.__proto__.__proto__, C.prototype);
- assert.equal(a1.__proto__.__proto__.__proto__.__proto__,
- HTMLElement.prototype);
-
- var a2 = new A();
- assert.equal('x-a5', a2.localName);
- assert.equal(a2.__proto__, A.prototype);
- assert.equal(a2.__proto__.__proto__, B.prototype);
- assert.equal(a2.__proto__.__proto__.__proto__, C.prototype);
- assert.equal(a2.__proto__.__proto__.__proto__.__proto__,
- HTMLElement.prototype);
- });
-
- test('document.registerElement createdCallback', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- var self;
- var createdCalls = 0;
-
- function A() {}
- A.prototype = {
- __proto__: HTMLElement.prototype,
- createdCallback: function() {
- createdCalls++;
- assert.isUndefined(a);
- assert.instanceOf(this, A);
- self = this;
- }
- };
-
- A = document.registerElement('x-a2', A);
-
- var a = new A;
- assert.equal(createdCalls, 1);
- assert.equal(self, a);
- });
-
- test('document.registerElement createdCallback upgrade', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
-
- function A() {}
- A.prototype = {
- __proto__: HTMLElement.prototype,
- createdCallback: function() {
- assert.isTrue(this.isCustom);
- assert.instanceOf(this, A);
- },
- isCustom: true
- };
-
- A = document.registerElement('x-a2-1', A);
- });
-
- test('document.registerElement attachedCallback, detachedCallback',
- function(done) {
- if (!document.registerElement || !Object.__proto__) {
- done();
- return;
- }
-
- var attachedCalls = 0;
- var detachedCalls = 0;
-
- function A() {}
- A.prototype = {
- __proto__: HTMLElement.prototype,
- attachedCallback: function() {
- attachedCalls++;
- assert.instanceOf(this, A);
- assert.equal(a, this);
- },
- detachedCallback: function() {
- detachedCalls++;
- assert.instanceOf(this, A);
- assert.equal(a, this);
- }
- };
-
- A = document.registerElement('x-a3', A);
-
- var a = new A;
- document.body.appendChild(a);
-
- // CE polyfill attachment is async, need to wait... (or force using takeRecords)
- setTimeout(function() {
- assert.equal(attachedCalls, 1);
- document.body.removeChild(a);
- setTimeout(function() {
- assert.equal(detachedCalls, 1);
- done();
- });
- });
- });
-
- test('document.registerElement attributeChangedCallback', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- var attributeChangedCalls = 0;
-
- function A() {}
- A.prototype = {
- __proto__: HTMLElement.prototype,
- attributeChangedCallback: function(name, oldValue, newValue) {
- attributeChangedCalls++;
- assert.equal(name, 'foo');
- switch (attributeChangedCalls) {
- case 1:
- assert.isNull(oldValue);
- assert.equal(newValue, 'bar');
- break;
- case 2:
- assert.equal(oldValue, 'bar');
- assert.equal(newValue, 'baz');
- break;
- case 3:
- assert.equal(oldValue, 'baz');
- assert.isNull(newValue);
- break;
- }
- console.log(arguments);
- }
- };
-
- A = document.registerElement('x-a4', A);
-
- var a = new A;
- assert.equal(attributeChangedCalls, 0);
- a.setAttribute('foo', 'bar');
- assert.equal(attributeChangedCalls, 1);
- a.setAttribute('foo', 'baz');
- assert.equal(attributeChangedCalls, 2);
- a.removeAttribute('foo');
- assert.equal(attributeChangedCalls, 3);
- });
-
- test('document.registerElement get reference, upgrade', function() {
- if (!document.registerElement || !Object.__proto__) {
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = '';
- // get reference (creates wrapper)
- div.firstChild;
-
- function A() {}
- A.prototype = {
- __proto__: HTMLElement.prototype,
- isCustom: true
- };
-
- A = document.registerElement('x-a6', A);
-
- // make test work when native custom elements is used with SD polyfill
- if (!window.CustomElements) {
- ShadowDOMPolyfill.rewrap(ShadowDOMPolyfill.unwrap(div.firstChild));
- }
-
- assert.isTrue(div.firstChild.isCustom);
- });
-
- test('document.registerElement optional option', function() {
- if (!document.registerElement || !Object.__proto__)
- return;
-
- document.registerElement('x-a7');
- var a = document.createElement('x-a7');
- assert.equal(Object.getPrototypeOf(Object.getPrototypeOf(a)),
- HTMLElement.prototype);
-
- document.registerElement('x-a8', {});
- var a2 = document.createElement('x-a8');
- assert.equal(Object.getPrototypeOf(Object.getPrototypeOf(a2)),
- HTMLElement.prototype);
-
- document.registerElement('x-a-span-2', {extends: 'span'});
- var a3 = document.createElement('span', 'x-a-span-2');
- assert.equal(Object.getPrototypeOf(Object.getPrototypeOf(a3)),
- HTMLElement.prototype);
- a3.localName = 'span';
- assert.equal('', a3.outerHTML);
- });
-});
diff --git a/tests/ShadowDOM/js/Element.js b/tests/ShadowDOM/js/Element.js
deleted file mode 100644
index 2d50eb3..0000000
--- a/tests/ShadowDOM/js/Element.js
+++ /dev/null
@@ -1,435 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Element', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var div;
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- div = null;
- });
-
- function skipTest () {}
-
- test('querySelector', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var b = div.firstChild.firstChild;
- assert.equal(div.querySelector('b'), b);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var srb = sr.firstChild;
-
- div.offsetHeight;
-
- assert.equal(div.querySelector('b'), b);
- assert.equal(sr.querySelector('b'), srb);
-
- var z = div.querySelector('z');
- assert.equal(z, null);
-
- var z = sr.querySelector('z');
- assert.equal(z, null);
- });
-
- test('querySelectorAll', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var as = div.querySelectorAll('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
- });
-
- skipTest('querySelectorAll', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '34';
- var a3 = sr.firstChild;
- var a4 = sr.lastChild;
-
- div.offsetHeight;
-
- var as = div.querySelectorAll('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as[1], a1);
-
- var as = sr.querySelectorAll('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a3);
- assert.equal(as[1], a4);
-
- var z = div.querySelectorAll('z');
- assert.equal(z.length, 0);
-
- var z = sr.querySelectorAll('z');
- assert.equal(z.length, 0);
- });
-
- test('querySelector deep', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- assert.equal(aa1, div.querySelector('div /deep/ aa'));
- assert.equal(bb, div.querySelector('div /deep/ bb'));
- });
-
- test('querySelector ::shadow', function() {
- var div = document.createElement('div');
- var div2 = document.createElement('div');
- div.appendChild(div2);
- var sr = div2.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- assert.equal(bb, div.querySelector('div::shadow bb'));
- });
-
- test('querySelectorAll deep', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var aa1 = div.firstChild;
- var aa2 = div.lastChild;
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- ['div /deep/ aa', 'div >>> aa'].forEach(function(selector) {
- var list = div.querySelectorAll(selector);
- assert.equal(2, list.length);
- assert.equal(aa1, list[0]);
- assert.equal(aa2, list[1]);
- });
-
- ['div /deep/ bb', 'div >>> bb'].forEach(function(selector) {
- var list = div.querySelectorAll(selector);
- assert.equal(1, list.length);
- assert.equal(bb, list[0]);
- });
- });
-
- test('querySelectorAll ::shadow', function() {
- var div = document.createElement('div');
- var div2 = document.createElement('div');
- div.appendChild(div2);
- var sr = div2.createShadowRoot();
- sr.innerHTML = '';
- var bb = sr.firstChild;
-
- div.offsetHeight;
-
- var list = div.querySelectorAll('div::shadow bb');
- assert.equal(2, list.length);
- assert.equal(bb, list[0]);
- });
-
- test('matches', function() {
- var div = document.createElement('div');
- div.classList.add('host-class');
- document.body.appendChild(div);
- var p = document.createElement('p');
- p.classList.add('child-class');
- div.appendChild(p);
- assert.isTrue(p.matches(':host(.host-class) *'));
- assert.isTrue(p.matches(':host::shadow .child-class'));
- assert.isTrue(p.matches('.host-class /deep/ p.child-class'));
- });
-
- skipTest('getElementsByTagName', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var as = div.getElementsByTagName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '34';
- var a3 = sr.firstChild;
- var a4 = sr.lastChild;
-
- div.offsetHeight;
-
- var as = div.getElementsByTagName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as[1], a1);
-
- var as = sr.getElementsByTagName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a3);
- assert.equal(as[1], a4);
-
- var z = div.getElementsByTagName('z');
- assert.equal(z.length, 0);
-
- var z = sr.getElementsByTagName('z');
- assert.equal(z.length, 0);
- });
-
- test('getElementsByTagName with colon', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var as = div.getElementsByTagName('a:b:c');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
- });
-
- test('getElementsByTagName with namespace', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
- var a2 = document.createElementNS('NS', 'a');
- var a3 = document.createElementNS('NS', 'A');
- div.appendChild(a2);
- div.appendChild(a3);
-
- var as = div.getElementsByTagName('a');
- assert.equal(as.length, 3);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
- assert.equal(as[2], a2);
- assert.equal(as.item(2), a2);
-
- var as = div.getElementsByTagName('A');
- assert.equal(as.length, 3);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
- assert.equal(as[2], a3);
- assert.equal(as.item(2), a3);
- });
-
- test('getElementsByTagNameNS', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '34';
-
- var z = div.getElementsByTagNameNS('NS', 'z');
- assert.equal(z.length, 0);
-
- var z = sr.getElementsByTagNameNS('NS', 'z');
- assert.equal(z.length, 0);
- });
-
- skipTest('getElementsByClassName', function() {
- var div = document.createElement('div');
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var as = div.getElementsByClassName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '34';
- var a3 = sr.firstChild;
- var a4 = sr.lastChild;
-
- div.offsetHeight;
-
- var as = div.getElementsByClassName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as[1], a1);
-
- var as = sr.getElementsByClassName('a');
- assert.equal(as.length, 2);
- assert.equal(as[0], a3);
- assert.equal(as[1], a4);
- });
-
- test('webkitCreateShadowRoot', function() {
- var div = document.createElement('div');
- if (!div.webkitCreateShadowRoot)
- return;
- var sr = div.webkitCreateShadowRoot();
- assert.instanceOf(sr, ShadowRoot);
- });
-
- test('getDestinationInsertionPoints', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var content = sr.firstChild;
-
- assertArrayEqual([content], a.getDestinationInsertionPoints());
- assertArrayEqual([content], b.getDestinationInsertionPoints());
-
- var sr2 = div.createShadowRoot();
- sr2.innerHTML = '';
- var contentB = sr2.firstChild;
-
- assertArrayEqual([content], a.getDestinationInsertionPoints());
- assertArrayEqual([contentB], b.getDestinationInsertionPoints());
- });
-
- test('getDestinationInsertionPoints redistribution', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var c = sr.firstChild;
- var content = c.firstChild;
- var sr2 = c.createShadowRoot();
- sr2.innerHTML = '';
- var contentB = sr2.firstChild;
-
- assertArrayEqual([content], a.getDestinationInsertionPoints());
- assertArrayEqual([content, contentB], b.getDestinationInsertionPoints());
- });
-
- test('getElementsByName', function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- div.innerHTML = '01';
- var a0 = div.firstChild;
- var a1 = div.lastChild;
-
- var as = document.getElementsByName('a');
- assert.instanceOf(as, NodeList);
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
-
- var doc = wrap(document);
- as = doc.getElementsByName('a');
- assert.instanceOf(as, NodeList);
- assert.equal(as.length, 2);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
- assert.equal(as[1], a1);
- assert.equal(as.item(1), a1);
-
- a0.setAttribute('name', '"odd"');
- as = document.getElementsByName('"odd"');
- assert.instanceOf(as, NodeList);
- assert.equal(as.length, 1);
- assert.equal(as[0], a0);
- assert.equal(as.item(0), a0);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- as = document.getElementsByName('a');
- assert.instanceOf(as, NodeList);
- assert.equal(as.length, 1);
- assert.equal(as[0], a1);
- assert.equal(as.item(0), a1);
- });
-
- test('sub shadow-root traversal', function() {
- var div = document.createElement("DIV");
- var sr = div.createShadowRoot();
- sr.innerHTML = "";
-
- var saal = sr.getElementsByTagName("aa");
- var sbbl = sr.getElementsByTagName("bb");
- assert.equal(saal.length, 1);
- assert.equal(sbbl.length, 1);
-
- var saa = saal [0];
- var sbb = sbbl [0];
- var abbl = saa.getElementsByTagName("bb");
- assert.equal(abbl.length, 1);
-
- var abb = abbl [0];
- assert.instanceOf(abb, HTMLElement);
- assert.equal(abb, sbb);
-
- var saal = sr.getElementsByTagNameNS("*", "aa");
- var sbbl = sr.getElementsByTagNameNS("*", "bb");
- assert.equal(saal.length, 1);
- assert.equal(sbbl.length, 1);
-
- var saa = saal [0];
- var sbb = sbbl [0];
- var abbl = saa.getElementsByTagNameNS("*", "bb");
- assert.equal(abbl.length, 1);
-
- var abb = abbl [0];
- assert.instanceOf(abb, HTMLElement);
- assert.equal(abb, sbb);
-
- var saal = sr.querySelectorAll("aa");
- var sbbl = sr.querySelectorAll("bb");
- assert.equal(saal.length, 1);
- assert.equal(sbbl.length, 1);
-
- var saa = saal [0];
- var sbb = sbbl [0];
- var abbl = saa.querySelectorAll("bb");
- assert.equal(abbl.length, 1);
-
- var abb = abbl [0];
- assert.instanceOf(abb, HTMLElement);
- assert.equal(abb, sbb);
-
- var saa = sr.querySelector("aa");
- var sbb = sr.querySelector("bb");
- var abb = saa.querySelector("bb");
- assert.instanceOf(abb, HTMLElement);
- assert.equal(abb, sbb);
- });
-});
diff --git a/tests/ShadowDOM/js/FormData.js b/tests/ShadowDOM/js/FormData.js
deleted file mode 100644
index f4b0677..0000000
--- a/tests/ShadowDOM/js/FormData.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('FormData', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- test('instanceof', function() {
- var fd = new FormData();
- assert.instanceOf(fd, FormData);
- });
-
- test('constructor', function() {
- var fd = new FormData();
- assert.equal(FormData, fd.constructor);
- });
-
- test('form element', function() {
- var formElement = document.createElement('form');
- var fd = new FormData(formElement)
- assert.instanceOf(fd, FormData);
- });
-
- test('wrap/unwrap', function() {
- var fd = new FormData();
- var unwrapped = unwrap(fd);
- var wrapped = wrap(unwrapped);
- assert.equal(fd, wrapped);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLAudioElement.js b/tests/ShadowDOM/js/HTMLAudioElement.js
deleted file mode 100644
index 5ff676a..0000000
--- a/tests/ShadowDOM/js/HTMLAudioElement.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLAudioElement', function() {
-
- test('instanceof', function() {
- var audio = document.createElement('audio');
- assert.instanceOf(audio, HTMLAudioElement);
- assert.instanceOf(audio, Audio);
- assert.instanceOf(audio, HTMLMediaElement);
- assert.instanceOf(audio, HTMLElement);
- });
-
- test('constructor', function() {
- var audio = document.createElement('audio');
- assert.equal(audio.constructor, HTMLAudioElement);
- });
-
- test('Audio', function() {
- var audio = new Audio();
- assert.instanceOf(audio, HTMLAudioElement);
- assert.instanceOf(audio, Audio);
- assert.instanceOf(audio, HTMLMediaElement);
- assert.instanceOf(audio, HTMLElement);
- });
-
- test('Audio arguments', function() {
- var audio = new Audio();
- assert.isFalse(audio.hasAttribute('src'));
- assert.equal(audio.getAttribute('preload'), 'auto');
-
- var src = 'foo.wav';
- var audio = new Audio(src);
- assert.equal(audio.getAttribute('src'), 'foo.wav');
- });
-
- test('Audio called as function', function() {
- assert.throws(Audio, TypeError);
- });
-
- test('Audio basics', function() {
- var audio = new Audio();
- assert.equal('audio', audio.localName);
-
- var div = document.createElement('div');
- div.appendChild(audio);
-
- assert.equal(div.firstChild, audio);
- assert.equal('', div.outerHTML);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLBodyElement.js b/tests/ShadowDOM/js/HTMLBodyElement.js
deleted file mode 100644
index 492faf6..0000000
--- a/tests/ShadowDOM/js/HTMLBodyElement.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLBodyElement', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- var div, div2;
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- if (div2 && div2.parentNode)
- div2.parentNode.removeChild(div2);
- div = div2 = undefined;
- });
-
- test('appendChild', function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- assert.equal(wrap(document.body.lastChild), div);
- });
-
- test('appendChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- assert.equal(doc.body.lastChild, div);
- });
-
- test('insertBefore', function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- div2 = document.createElement('div');
- document.body.insertBefore(div2, div);
- assert.equal(wrap(document.body.lastChild), div);
- assert.equal(div2.nextSibling, div);
- assert.equal(div.previousSibling, div2);
- });
-
- test('insertBefore (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- div2 = doc.createElement('div');
- doc.body.insertBefore(div2, div);
- assert.equal(doc.body.lastChild, div);
- assert.equal(div2.nextSibling, div);
- assert.equal(div.previousSibling, div2);
- });
-
- test('replaceChild', function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- div2 = document.createElement('div');
- document.body.replaceChild(div2, div);
- assert.equal(wrap(document.body.lastChild), div2);
- assert.isNull(div.parentNode);
- });
-
- test('replaceChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- div2 = doc.createElement('div');
- doc.body.replaceChild(div2, div);
- assert.equal(doc.body.lastChild, div2);
- assert.isNull(div.parentNode);
- });
-
- test('removeChild', function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- document.body.removeChild(div);
- assert.isNull(div.parentNode);
- });
-
- test('removeChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- doc.body.removeChild(div);
- assert.isNull(div.parentNode);
- });
-
- test('dispatchEvent', function() {
- var calls = 0;
- var doc = wrap(document);
- var f;
- document.body.addEventListener('x', f = function(e) {
- calls++;
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, doc.body);
- assert.equal(this, doc.body);
- if (calls === 2)
- document.body.removeEventListener('x', f);
- });
-
- document.body.dispatchEvent(new Event('x'));
- doc.body.dispatchEvent(new Event('x'));
-
- assert.equal(calls, 2);
- });
-
- test('document.body.contains', function() {
- var doc = wrap(document);
- assert.isTrue(doc.body.contains(doc.body.firstChild));
- assert.isTrue(doc.body.contains(document.body.firstChild));
- assert.isTrue(document.body.contains(doc.body.firstChild));
- assert.isTrue(document.body.contains(document.body.firstChild));
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('body'), HTMLBodyElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLBodyElement, document.createElement('body').constructor);
- });
-});
diff --git a/tests/ShadowDOM/js/HTMLButtonElement.js b/tests/ShadowDOM/js/HTMLButtonElement.js
deleted file mode 100644
index f09525c..0000000
--- a/tests/ShadowDOM/js/HTMLButtonElement.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLButtonElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var button = document.createElement('button');
- form.appendChild(button);
- assert.equal(button.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('button'), HTMLButtonElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLButtonElement,
- document.createElement('button').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLCanvasElement.js b/tests/ShadowDOM/js/HTMLCanvasElement.js
deleted file mode 100644
index 4a2d67e..0000000
--- a/tests/ShadowDOM/js/HTMLCanvasElement.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLCanvasElement', function() {
-
- var iconUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHklEQVQ4T2Nk+A+EFADGUQMYRsOAYTQMgHloGKQDAJXkH/HZpKBrAAAAAElFTkSuQmCC';
-
- test('getContext null', function() {
- var canvas = document.createElement('canvas');
- // IE10 returns undefined instead of null
- assert.isTrue(canvas.getContext('unknown') == null);
- });
-
- test('getContext 2d', function() {
- var canvas = document.createElement('canvas');
- var context = canvas.getContext('2d');
- assert.instanceOf(context, CanvasRenderingContext2D);
- assert.equal(context.canvas, canvas);
- });
-
- test('getContext webgl', function() {
- // IE10 does not have WebGL.
- if (typeof WebGLRenderingContext === 'undefined')
- return;
-
- var canvas = document.createElement('canvas');
- var context = null;
- // Firefox throws exception if graphics card is not supported
- try {
- context = canvas.getContext('webgl');
- }
- catch(ex) {
- }
- // Chrome returns null if the graphics card is not supported
- assert.isTrue(context === null || context instanceof WebGLRenderingContext);
-
- if (context != null)
- assert.equal(context.canvas, canvas);
- });
-
- test('context instance properties', function() {
- var canvas = document.createElement('canvas');
- var context = canvas.getContext('2d');
-
- assert.isString(context.fillStyle);
- assert.isString(context.strokeStyle);
- assert.isString(context.textBaseline);
- assert.isString(context.textAlign);
- assert.isString(context.font);
-
- // lineDashOffset is not available in Firefox 25
- // assert.isNumber(context.lineDashOffset);
-
- assert.isString(context.shadowColor);
- assert.isNumber(context.shadowBlur);
- assert.isNumber(context.shadowOffsetY);
- assert.isNumber(context.shadowOffsetX);
- assert.isNumber(context.miterLimit);
- assert.isString(context.lineJoin);
- assert.isString(context.lineCap);
- assert.isNumber(context.lineWidth);
- assert.isNumber(context.globalAlpha);
- });
-
- test('2d drawImage using new Image', function(done) {
- var canvas = document.createElement('canvas');
- var context = canvas.getContext('2d');
-
- // var img = new Image();
- var img = document.createElement('img');
- img.width = img.height = 32;
- img.onload = function() {
- context.drawImage(img, 0, 0);
- done();
- };
- img.src = iconUrl;
- });
-
- test('2d drawImage', function(done) {
- var canvas = document.createElement('canvas');
- var context = canvas.getContext('2d');
-
- var img = document.createElement('img');
- img.onload = function() {
- context.drawImage(img, 0, 0);
- done();
- };
- img.src = iconUrl;
- });
-
- test('2d createPattern', function(done) {
- var canvas = document.createElement('canvas');
- var context = canvas.getContext('2d');
- var img = document.createElement('img');
- img.onload = function() {
- var pattern = context.createPattern(img, 'repeat');
- done();
- };
- img.src = iconUrl;
- });
-
- test('WebGL texImage2D', function(done) {
- var canvas = document.createElement('canvas');
- var gl = null;
- // Firefox throws exception if graphics card is not supported
- try {
- gl = canvas.getContext('webgl');
- } catch (ex) {
- console.error(ex);
- }
- // IE10 does not have WebGL.
- // Chrome returns null if the graphics card is not supported
- if (!gl) {
- done();
- return;
- }
-
- var imageData = document.createElement('canvas').getContext('2d').
- createImageData(16, 16);
- var arrayBufferView = new Uint8Array(16 * 16 * 4);
-
- var img = document.createElement('img');
- img.onload = function() {
- var texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,
- imageData);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
- 16, 16, 0,
- gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView);
-
- done();
- };
- img.src = iconUrl;
- });
-
- test('WebGL context instance properties', function() {
- var canvas = document.createElement('canvas');
- var gl = null;
- // Firefox throws exception if graphics card is not supported
- try {
- gl = canvas.getContext('webgl');
- } catch (ex) {
- }
- // IE10 does not have WebGL.
- // Chrome returns null if the graphics card is not supported
- if (!gl) {
- return;
- }
-
- assert.isNumber(gl.drawingBufferHeight);
- assert.isNumber(gl.drawingBufferWidth);
- });
-
- test('WebGL texSubImage2D', function(done) {
- var canvas = document.createElement('canvas');
- var gl = null;
- // Firefox throws exception if graphics card is not supported
- try {
- gl = canvas.getContext('webgl');
- } catch(ex) {
- }
- // IE10 does not have WebGL.
- // Chrome returns null if the graphics card is not supported
- if (!gl) {
- done();
- return;
- }
-
- var arrayBufferView = new Uint8Array(16 * 16 * 4);
-
- var img = document.createElement('img');
- img.onload = function() {
- var texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, img);
- gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0,
- 16, 16,
- gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView);
- done();
- };
- img.src = iconUrl;
- });
-
- test('width', function() {
- var canvas = document.createElement('canvas');
- assert.isNumber(canvas.width);
- });
-
- test('height', function() {
- var canvas = document.createElement('canvas');
- assert.isNumber(canvas.height);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('canvas'), HTMLCanvasElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLCanvasElement,
- document.createElement('canvas').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLContentElement.js b/tests/ShadowDOM/js/HTMLContentElement.js
deleted file mode 100644
index ba0734e..0000000
--- a/tests/ShadowDOM/js/HTMLContentElement.js
+++ /dev/null
@@ -1,245 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLContentElement', function() {
-
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- test('select', function() {
- var el = document.createElement('content');
- assert.equal(el.select, null);
-
- el.select = '.xxx';
- assert.equal(el.select, '.xxx');
- assert.isTrue(el.hasAttribute('select'));
- assert.equal(el.getAttribute('select'), '.xxx');
-
- el.select = '.xxx';
- assert.equal(el.select, '.xxx');
- assert.isTrue(el.hasAttribute('select'));
- assert.equal(el.getAttribute('select'), '.xxx');
- });
-
- test('getDistributedNodes', function() {
- var host = document.createElement('div');
- host.innerHTML = 'ab';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var content = sr.firstChild;
-
- assertArrayEqual(content.getDistributedNodes(), [a, b]);
-
- content.select = 'a';
- assertArrayEqual(content.getDistributedNodes(), [a]);
-
- content.select = 'b';
- assertArrayEqual(content.getDistributedNodes(), [b]);
- });
-
- test('getDistributedNodes add document fragment with content', function() {
- var host = document.createElement('div');
- host.innerHTML = ' ';
- var root = host.createShadowRoot();
- var df = document.createDocumentFragment();
- df.appendChild(document.createTextNode(' '));
- var content = df.appendChild(document.createElement('content'));
- df.appendChild(document.createTextNode(' '));
- root.appendChild(df);
-
- assert.equal(content.getDistributedNodes().length, 7);
- assertArrayEqual(content.getDistributedNodes(), host.childNodes);
- });
-
- test('getDistributedNodes add content deep inside tree', function() {
- var host = document.createElement('div');
- host.innerHTML = ' ';
- var root = host.createShadowRoot();
- var b = document.createElement('b');
- var content = b.appendChild(document.createElement('content'));
- content.select = '*';
- root.appendChild(b);
-
- assert.equal(content.getDistributedNodes().length, 3);
- assertArrayEqual(content.getDistributedNodes(), host.children);
- });
-
- test('getDistributedNodes add content deeper inside tree', function() {
- var foo = document.createElement('div');
- var fooRoot = foo.createShadowRoot();
- fooRoot.innerHTML = '
' +
- '
item1
item2
item3
' +
- '
';
-
- var bar = fooRoot.firstChild;
- var barRoot = bar.createShadowRoot();
- barRoot.innerHTML = '
';
-
- var zot = barRoot.firstChild;
- var zotRoot = zot.createShadowRoot();
- zotRoot.innerHTML = '';
- var content = zotRoot.firstChild;
-
- assert.equal(content.getDistributedNodes().length, 3);
- assertArrayEqual(content.getDistributedNodes(), fooRoot.firstChild.children);
- });
-
- test('Adding tree with content again', function() {
- var host = document.createElement('div');
- host.innerHTML = '
Content
';
-
- var t = document.createElement('template');
- t.innerHTML = '
[]
';
-
- var sr = host.createShadowRoot();
- sr.appendChild(t.content.cloneNode(true));
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML,
- '
[
Content
]
');
- });
-
- test('adding a new content element to a shadow tree', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var c = sr.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- var content = document.createElement('content');
- content.select = 'b';
- c.appendChild(content);
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- c.removeChild(content);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-
- test('adding a new content element to a shadow tree 2', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var c = sr.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- var d = document.createElement('d');
- var content = d.appendChild(document.createElement('content'));
- content.select = 'b';
- c.appendChild(d);
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- c.removeChild(d);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-
- test('restricting select further', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var c = sr.firstChild;
- var content = c.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- content.select = 'b';
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-
- test('Mutating content fallback', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var content = sr.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- content.textContent = 'fallback';
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
-
- var b = content.appendChild(document.createElement('b'));
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
-
- content.removeChild(b);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
- });
-
- test('Mutating content fallback 2', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var b = sr.firstChild;
- var content = b.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- content.textContent = 'fallback';
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
-
- var c = content.appendChild(document.createElement('c'));
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
-
- content.removeChild(c);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, 'fallback');
- });
-
- test('getDistributedNodes outside shadow dom', function() {
- var content = document.createElement('content');
- assert.deepEqual(content.getDistributedNodes(), []);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('content'), HTMLContentElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLContentElement,
- document.createElement('content').constructor);
- });
-});
diff --git a/tests/ShadowDOM/js/HTMLElement.js b/tests/ShadowDOM/js/HTMLElement.js
deleted file mode 100644
index 488df58..0000000
--- a/tests/ShadowDOM/js/HTMLElement.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLElement', function() {
-
- var div;
-
- setup(function() {
- div = document.body.appendChild(document.createElement('div'));
- div.style.cssText =
- 'width: 100px; height: 100px; overflow: scroll;' +
- 'position: absolute; top: 100px; left: 100px;' +
- 'border: 10px solid red';
- var sr = div.createShadowRoot();
- var div2 = sr.appendChild(document.createElement('div'));
- div2.style.cssText = 'width: 1000px; height: 1000px';
- });
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- });
-
- test('scrollTop', function() {
- assert.equal(div.scrollTop, 0);
- div.scrollTop = 100;
- assert.equal(div.scrollTop, 100);
- });
-
- test('scrollLeft', function() {
- assert.equal(div.scrollLeft, 0);
- div.scrollLeft = 100;
- assert.equal(div.scrollLeft, 100);
- });
-
- test('scrollHeight', function() {
- assert.equal(div.scrollHeight, 1000);
- });
-
- test('scrollWidth', function() {
- assert.equal(div.scrollHeight, 1000);
- });
-
- test('clientHeight', function() {
- div.style.overflow = 'hidden';
- assert.equal(div.clientHeight, 100);
- });
-
- test('clientLeft', function() {
- div.style.overflow = 'hidden';
- assert.equal(div.clientLeft, 10);
- });
-
- test('clientTop', function() {
- assert.equal(div.clientTop, 10);
- });
-
- test('clientWidth', function() {
- div.style.overflow = 'hidden';
- assert.equal(div.clientWidth, 100);
- });
-
- test('offsetHeight', function() {
- assert.equal(div.offsetHeight, 120);
- });
-
- test('offsetLeft', function() {
- assert.equal(div.offsetLeft, 100);
- });
-
- test('offsetTop', function() {
- assert.equal(div.offsetTop, 100);
- });
-
- test('offsetWidth', function() {
- assert.equal(div.offsetWidth, 120);
- });
-
- test('script innerHTML', function() {
- var script = document.createElement('script');
- var html = '{{y}}';
- script.innerHTML = html;
- assert.equal(script.innerHTML, html);
- });
-
- test('script textContent', function() {
- var script = document.createElement('script');
- var html = '{{y}}';
- script.innerHTML = html;
- assert.equal(script.textContent, html);
- });
-
- test('comment innerHTML', function() {
- var div = document.createElement('div');
- var comment = document.createComment('&\u00A0<>"');
- div.appendChild(comment);
- assert.equal(div.innerHTML, '');
- });
-
- test('hidden property', function() {
- var div = document.createElement('div');
- assert.isFalse(div.hidden);
- div.hidden = true;
- assert.isTrue(div.hasAttribute('hidden'));
- assert.equal(div.getAttribute('hidden'), '');
- div.hidden = false;
- assert.isFalse(div.hasAttribute('hidden'));
- });
-
- test('img outerHTML in XHTML documents', function() {
- var docType = document.implementation.createDocumentType('html', '-//W3C//DTD XHTML 1.0 Transitional//EN',
- 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
- var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', docType);
- var img = doc.createElement('img');
- assert.equal(img.outerHTML, '');
- });
-});
diff --git a/tests/ShadowDOM/js/HTMLFieldSetElement.js b/tests/ShadowDOM/js/HTMLFieldSetElement.js
deleted file mode 100644
index 522a833..0000000
--- a/tests/ShadowDOM/js/HTMLFieldSetElement.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLFieldSetElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var fieldSet = document.createElement('fieldset');
- form.appendChild(fieldSet);
- assert.equal(fieldSet.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('fieldset'), HTMLFieldSetElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLFieldSetElement,
- document.createElement('fieldset').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLFormElement.js b/tests/ShadowDOM/js/HTMLFormElement.js
deleted file mode 100644
index 0a08aff..0000000
--- a/tests/ShadowDOM/js/HTMLFormElement.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLFormElement', function() {
-
- test('elements', function() {
- var form = document.createElement('form');
- var input = document.createElement('input');
- form.appendChild(input);
- assert.instanceOf(form.elements, HTMLCollection);
- assert.equal(form.elements.length, 1);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('form'), HTMLFormElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLFormElement,
- document.createElement('form').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLHeadElement.js b/tests/ShadowDOM/js/HTMLHeadElement.js
deleted file mode 100644
index cfa8866..0000000
--- a/tests/ShadowDOM/js/HTMLHeadElement.js
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLHeadElement', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- var div, div2;
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- if (div2 && div2.parentNode)
- div2.parentNode.removeChild(div2);
- div = div2 = undefined;
- });
-
- test('appendChild', function() {
- div = document.createElement('div');
- document.head.appendChild(div);
- assert.equal(wrap(document.head.lastChild), div);
- });
-
- test('appendChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- assert.equal(doc.body.lastChild, div);
- });
-
- test('insertBefore', function() {
- div = document.createElement('div');
- document.head.appendChild(div);
- div2 = document.createElement('div');
- document.head.insertBefore(div2, div);
- assert.equal(wrap(document.head.lastChild), div);
- assert.equal(div2.nextSibling, div);
- assert.equal(div.previousSibling, div2);
- });
-
- test('insertBefore (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- div2 = doc.createElement('div');
- doc.body.insertBefore(div2, div);
- assert.equal(doc.body.lastChild, div);
- assert.equal(div2.nextSibling, div);
- assert.equal(div.previousSibling, div2);
- });
-
- test('replaceChild', function() {
- div = document.createElement('div');
- document.head.appendChild(div);
- div2 = document.createElement('div');
- document.head.replaceChild(div2, div);
- assert.equal(wrap(document.head.lastChild), div2);
- assert.isNull(div.parentNode);
- });
-
- test('replaceChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- div2 = doc.createElement('div');
- doc.body.replaceChild(div2, div);
- assert.equal(doc.body.lastChild, div2);
- assert.isNull(div.parentNode);
- });
-
- test('removeChild', function() {
- div = document.createElement('div');
- document.head.appendChild(div);
- document.head.removeChild(div);
- assert.isNull(div.parentNode);
- });
-
- test('removeChild (through wrapper)', function() {
- var doc = wrap(document);
- div = doc.createElement('div');
- doc.body.appendChild(div);
- doc.body.removeChild(div);
- assert.isNull(div.parentNode);
- });
-
- test('document.head.contains', function() {
- var doc = wrap(document);
- assert.isTrue(doc.head.contains(doc.head.firstChild));
- assert.isTrue(doc.head.contains(document.head.firstChild));
- assert.isTrue(document.head.contains(doc.head.firstChild));
- assert.isTrue(document.head.contains(document.head.firstChild));
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('head'), HTMLHeadElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLHeadElement,
- document.createElement('head').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLHtmlElement.js b/tests/ShadowDOM/js/HTMLHtmlElement.js
deleted file mode 100644
index be2e8a6..0000000
--- a/tests/ShadowDOM/js/HTMLHtmlElement.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLHtmlElement', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- test('instanceof', function() {
- var doc = wrap(document);
- assert.instanceOf(doc.documentElement, HTMLHtmlElement);
- assert.equal(wrap(document.documentElement), doc.documentElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLHtmlElement,
- document.createElement('html').constructor);
- });
-
- test('appendChild', function() {
- var doc = wrap(document);
-
- var a = document.createComment('a');
- var b = document.createComment('b');
-
- document.documentElement.appendChild(a);
- assert.equal(doc.documentElement.lastChild, a);
-
- doc.documentElement.appendChild(b);
- assert.equal(doc.documentElement.lastChild, b);
- });
-
- test('insertBefore', function() {
- var comment = document.createComment('comment');
- var root = document.documentElement;
- root.insertBefore(comment, root.firstChild);
- assert.equal(wrap(root.firstChild), comment);
- });
-
- test('replaceChild', function() {
- var comment = document.createComment('comment');
- var comment2 = document.createComment('comment2');
- var root = document.documentElement;
- root.insertBefore(comment, root.firstChild);
- assert.equal(wrap(root.firstChild), comment);
- root.replaceChild(comment2, root.firstChild);
- });
-
- test('matches', function() {
- // From jQuery.
- var html = document.documentElement;
- var matches = html.matchesSelector ||
- html.mozMatchesSelector ||
- html.webkitMatchesSelector ||
- html.msMatchesSelector;
-
- assert.isTrue(matches.call(document.body, 'body'));
- assert.isTrue(matches.call(wrap(document.body), 'body'));
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLImageElement.js b/tests/ShadowDOM/js/HTMLImageElement.js
deleted file mode 100644
index 08bb725..0000000
--- a/tests/ShadowDOM/js/HTMLImageElement.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLImageElement', function() {
-
- var iconUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHklEQVQ4T2Nk+A+EFADGUQMYRsOAYTQMgHloGKQDAJXkH/HZpKBrAAAAAElFTkSuQmCC';
-
- test('instanceof', function() {
- var img = document.createElement('img');
- assert.instanceOf(img, HTMLImageElement);
- assert.instanceOf(img, Image);
- assert.instanceOf(img, HTMLElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLImageElement, document.createElement('img').constructor);
- assert.equal(HTMLImageElement, new Image().constructor);
- });
-
- test('Image', function() {
- var img = new Image();
- assert.instanceOf(img, HTMLImageElement);
- assert.instanceOf(img, Image);
- assert.instanceOf(img, HTMLElement);
- });
-
- test('Image arguments', function() {
- var img = new Image(32);
- assert.equal(img.width, 32);
- assert.equal(img.height, 0);
-
- var img = new Image(undefined, 32);
- assert.equal(img.width, 0);
- assert.equal(img.height, 32);
- });
-
- test('Image called as function', function() {
- assert.throws(Image, TypeError);
- });
-
- test('Image basics', function() {
- var img = new Image();
- assert.equal('img', img.localName);
-
- var div = document.createElement('div');
- div.appendChild(img);
-
- assert.equal(div.firstChild, img);
- assert.equal('
', div.outerHTML);
-
- assert.equal(img.width, 0);
- assert.equal(img.height, 0);
- });
-
- test('Image load', function(done) {
- var img = new Image();
- img.addEventListener('load', function() {
- done();
- });
- img.src = iconUrl;
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLInputElement.js b/tests/ShadowDOM/js/HTMLInputElement.js
deleted file mode 100644
index 6d0317d..0000000
--- a/tests/ShadowDOM/js/HTMLInputElement.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLInputElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var input = document.createElement('input');
- form.appendChild(input);
- assert.equal(input.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('input'), HTMLInputElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLInputElement,
- document.createElement('input').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLKeygenElement.js b/tests/ShadowDOM/js/HTMLKeygenElement.js
deleted file mode 100644
index f71a380..0000000
--- a/tests/ShadowDOM/js/HTMLKeygenElement.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLKeygenElement', function() {
- // Not implemented in Firefox.
- if (!window.HTMLKeygenElement)
- return;
-
- test('form', function() {
- var form = document.createElement('form');
- var keygen = document.createElement('keygen');
- form.appendChild(keygen);
- assert.equal(keygen.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('keygen'), HTMLKeygenElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLKeygenElement,
- document.createElement('keygen').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLLabelElement.js b/tests/ShadowDOM/js/HTMLLabelElement.js
deleted file mode 100644
index 52ace50..0000000
--- a/tests/ShadowDOM/js/HTMLLabelElement.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLLabelElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var label = document.createElement('label');
- var input = document.createElement('input');
- form.appendChild(label);
- label.appendChild(input);
- assert.equal(label.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('label'), HTMLLabelElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLLabelElement,
- document.createElement('label').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLLegendElement.js b/tests/ShadowDOM/js/HTMLLegendElement.js
deleted file mode 100644
index 76f215f..0000000
--- a/tests/ShadowDOM/js/HTMLLegendElement.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLLegendElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var fieldSet = document.createElement('fieldset');
- var legend = document.createElement('legend');
- form.appendChild(fieldSet);
- fieldSet.appendChild(legend);
- assert.equal(legend.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('legend'), HTMLLegendElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLLegendElement,
- document.createElement('legend').constructor);
- });
-
-
-});
diff --git a/tests/ShadowDOM/js/HTMLObjectElement.js b/tests/ShadowDOM/js/HTMLObjectElement.js
deleted file mode 100644
index 9c6b75f..0000000
--- a/tests/ShadowDOM/js/HTMLObjectElement.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLObjectElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var object = document.createElement('object');
- form.appendChild(object);
- assert.equal(object.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('object'), HTMLObjectElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLObjectElement,
- document.createElement('object').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLOptionElement.js b/tests/ShadowDOM/js/HTMLOptionElement.js
deleted file mode 100644
index ee11c6b..0000000
--- a/tests/ShadowDOM/js/HTMLOptionElement.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLOptionElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var select = document.createElement('select');
- var option = document.createElement('option');
- form.appendChild(select);
- select.appendChild(option);
- assert.equal(option.form, form);
- });
-
- test('instanceof', function() {
- var option = document.createElement('option');
- assert.instanceOf(option, HTMLOptionElement);
- assert.instanceOf(option, Option);
- assert.instanceOf(option, HTMLElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLOptionElement,
- document.createElement('option').constructor);
- assert.equal(HTMLOptionElement, new Option().constructor);
- });
-
- test('Option', function() {
- var option = new Option();
- assert.instanceOf(option, HTMLOptionElement);
- assert.instanceOf(option, Option);
- assert.instanceOf(option, HTMLElement);
- });
-
- test('Option arguments', function() {
- var option = new Option();
- assert.equal(option.text, '');
- assert.equal(option.value, '');
- assert.isFalse(option.defaultSelected);
- assert.isFalse(option.selected);
-
- var option = new Option(' more text ');
- assert.equal(option.text, 'more text');
- // on IE10, the value includes the surrounding spaces; trim to workaround
- assert.equal(option.value.trim(), 'more text');
- assert.isFalse(option.defaultSelected);
- assert.isFalse(option.selected);
-
- var option = new Option('text', 'value');
- assert.equal(option.text, 'text');
- assert.equal(option.value, 'value');
- assert.isFalse(option.defaultSelected);
- assert.isFalse(option.selected);
-
- var option = new Option('text', 'value', true);
- assert.equal(option.text, 'text');
- assert.equal(option.value, 'value');
- assert.isTrue(option.defaultSelected);
- assert.isFalse(option.selected);
-
- var option = new Option('text', 'value', true, true);
- assert.equal(option.text, 'text');
- assert.equal(option.value, 'value');
- assert.isTrue(option.defaultSelected);
- assert.isTrue(option.selected);
- });
-
- test('Option called as function', function() {
- assert.throws(Option, TypeError);
- });
-
- test('Option basics', function() {
- var option = new Option();
- assert.equal('option', option.localName);
-
- var select = document.createElement('select');
- select.appendChild(option);
-
- assert.equal(select.firstChild, option);
- assert.equal('', select.outerHTML);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLOutputElement.js b/tests/ShadowDOM/js/HTMLOutputElement.js
deleted file mode 100644
index 6a77412..0000000
--- a/tests/ShadowDOM/js/HTMLOutputElement.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLOutputElement', function() {
- // Not implemented in IE10.
- if (!window.HTMLOutputElement)
- return;
-
- test('form', function() {
- var form = document.createElement('form');
- var output = document.createElement('output');
- form.appendChild(output);
- assert.equal(output.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('output'), HTMLOutputElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLOutputElement,
- document.createElement('output').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLSelectElement.js b/tests/ShadowDOM/js/HTMLSelectElement.js
deleted file mode 100644
index b13f960..0000000
--- a/tests/ShadowDOM/js/HTMLSelectElement.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLSelectElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var select = document.createElement('select');
- form.appendChild(select);
- assert.equal(select.form, form);
- });
-
- test('add', function() {
- var select = document.createElement('select');
-
- var a = document.createElement('option');
- a.text = 'a';
- select.add(a);
- assert.equal(select.firstChild, a);
-
- var b = document.createElement('option');
- b.text = 'b';
- select.add(b, a);
- assert.equal(select.firstChild, b);
- assert.equal(select.lastChild, a);
-
- // https://code.google.com/p/chromium/issues/detail?id=345345
- if (/WebKit/.test(navigator.userAgent))
- return;
-
- var c = document.createElement('option');
- c.text = 'c';
- select.add(c, 1);
- assert.equal(select.firstChild, b);
- assert.equal(b.nextSibling, c);
- assert.equal(select.lastChild, a);
- });
-
- test('remove', function() {
- var select = document.createElement('select');
-
- var a = document.createElement('option');
- a.text = 'a';
- select.appendChild(a);
-
- var b = document.createElement('option');
- b.text = 'b';
- select.appendChild(b);
-
- var c = document.createElement('option');
- c.text = 'c';
- select.appendChild(c);
-
- select.remove(a);
- assert.equal(select.firstChild, b);
- assert.equal(select.lastChild, c);
-
- select.remove(1);
- assert.equal(select.firstChild, b);
- assert.equal(select.lastChild, b);
- });
-
- test('remove no args', function() {
- var div = document.createElement('div');
- var select = div.appendChild(document.createElement('select'));
-
- var a = document.createElement('option');
- a.text = 'a';
- select.appendChild(a);
- var b = document.createElement('option');
- b.text = 'b';
- select.appendChild(b);
-
- assert.equal(select.parentNode, div);
-
- select.remove();
- assert.equal(select.firstChild, a);
- assert.equal(select.lastChild, b);
- assert.equal(select.parentNode, null);
- assert.equal(div.firstChild, null);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('select'), HTMLSelectElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLSelectElement,
- document.createElement('select').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLShadowElement.js b/tests/ShadowDOM/js/HTMLShadowElement.js
deleted file mode 100644
index 71c2398..0000000
--- a/tests/ShadowDOM/js/HTMLShadowElement.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLShadowElement', function() {
-
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- test('instanceof HTMLShadowElement', function() {
- var host = document.createElement('div');
- host.innerHTML = 'ab';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = 'abc';
- var shadow = sr.firstElementChild;
-
- host.offsetWidth;
- assert.isTrue(shadow instanceof HTMLShadowElement);
-
- var sr2 = host.createShadowRoot();
- sr2.innerHTML = 'def';
- var shadow2 = sr2.firstElementChild;
-
- host.offsetWidth;
- assert.isTrue(shadow instanceof HTMLShadowElement);
-
- assert.isTrue(shadow2 instanceof HTMLShadowElement);
-
- assert.equal(unwrap(host).innerHTML, 'daabcf');
- });
-
- test('constructor', function() {
- assert.equal(HTMLShadowElement,
- document.createElement('shadow').constructor);
- });
-
- test('adding a new shadow element to a shadow tree', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
-
- var sr2 = host.createShadowRoot();
- sr2.innerHTML = '';
- var b = sr2.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- var shadow = document.createElement('shadow');
- b.appendChild(shadow);
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- b.removeChild(shadow);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-
- test('Mutating shadow fallback (fallback support has been removed)', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var shadow = sr.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- shadow.textContent = 'fallback';
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- var b = shadow.appendChild(document.createElement('b'));
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- shadow.removeChild(b);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-
- test('Mutating shadow fallback 2 (fallback support has been removed)',
- function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = '';
- var b = sr.firstChild;
- var shadow = b.firstChild;
-
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- shadow.textContent = 'fallback';
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- var c = shadow.appendChild(document.createElement('c'));
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
-
- shadow.removeChild(c);
- host.offsetHeight;
- assert.equal(unwrap(host).innerHTML, '');
- });
-});
diff --git a/tests/ShadowDOM/js/HTMLTableElement.js b/tests/ShadowDOM/js/HTMLTableElement.js
deleted file mode 100644
index 943cb93..0000000
--- a/tests/ShadowDOM/js/HTMLTableElement.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLTableElement', function() {
-
- test('instanceof', function() {
- var table = createTable();
- assert.instanceOf(table, HTMLTableElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLTableElement,
- document.createElement('table').constructor);
- });
-
- test('caption', function() {
- var table = createTable();
- assert.equal(table.caption.localName, 'caption');
- });
-
- test('createCaption', function() {
- var table = createTable();
- var caption = table.createCaption();
- assert.equal(caption.localName, 'caption');
- assert.instanceOf(caption, HTMLElement);
- });
-
- test('tHead', function() {
- var table = createTable();
- assert.equal(table.tHead.localName, 'thead');
- assert.instanceOf(table.tHead, HTMLTableSectionElement);
- });
-
- test('createTHead', function() {
- var table = createTable();
- var thead = table.createTHead();
- assert.equal(thead.localName, 'thead');
- assert.instanceOf(thead, HTMLTableSectionElement);
- });
-
- test('tFoot', function() {
- var table = createTable();
- assert.equal(table.tFoot.localName, 'tfoot');
- assert.instanceOf(table.tFoot, HTMLTableSectionElement);
- });
-
- test('createTFoot', function() {
- var table = createTable();
- var tfoot = table.createTFoot();
- assert.equal(tfoot.localName, 'tfoot');
- assert.instanceOf(tfoot, HTMLTableSectionElement);
- });
-
- test('tBodies', function() {
- var table = createTable();
- assert.instanceOf(table.tBodies, HTMLCollection);
- assert.equal(table.tBodies.length, 2);
-
- assert.equal(table.tBodies[0], table.querySelector('tbody'));
- });
-
- test('createTBody', function() {
- var table = createTable();
- var tbody = table.createTBody();
- assert.equal(tbody.localName, 'tbody');
- assert.instanceOf(tbody, HTMLTableSectionElement);
- });
-
- test('rows', function() {
- var table = createTable();
- assert.instanceOf(table.rows, HTMLCollection);
- assert.equal(table.rows.length, 8);
- });
-
- test('insertRow', function() {
- var table = createTable();
- var tr = table.insertRow(1);
- assert.instanceOf(tr, HTMLTableRowElement);
- assert.equal(tr.localName, 'tr');
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLTableRowElement.js b/tests/ShadowDOM/js/HTMLTableRowElement.js
deleted file mode 100644
index 333c8d3..0000000
--- a/tests/ShadowDOM/js/HTMLTableRowElement.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLTableRowElement', function() {
-
- test('instanceof', function() {
- var table = createTable();
- var row = table.querySelector('tr');
- assert.instanceOf(row, HTMLTableRowElement);
- });
-
- test('constructor', function() {
- var table = createTable();
- var row = table.querySelector('tr');
- assert.equal(HTMLTableRowElement, row.constructor);
- });
-
- test('cells', function() {
- var table = createTable();
- var row = table.querySelector('tr');
- assert.instanceOf(row.cells, HTMLCollection);
- assert.equal(row.cells.length, 3);
- });
-
- test('insertCell', function() {
- var table = createTable();
- var row = table.querySelector('tr');
- var newCell = row.insertCell(0);
- assert.equal(newCell.localName, 'td');
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLTableSectionElement.js b/tests/ShadowDOM/js/HTMLTableSectionElement.js
deleted file mode 100644
index 3ffe537..0000000
--- a/tests/ShadowDOM/js/HTMLTableSectionElement.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLTableSectionElement', function() {
-
- test('instanceof', function() {
- var table = createTable();
- var thead = table.querySelector('thead');
- assert.instanceOf(thead, HTMLTableSectionElement);
- var tfoot = table.querySelector('tfoot');
- assert.instanceOf(tfoot, HTMLTableSectionElement);
- });
-
- test('constructor', function() {
- var table = createTable();
- var thead = table.querySelector('thead');
- assert.equal(HTMLTableSectionElement, thead.constructor);
- var tfoot = table.querySelector('tfoot');
- assert.equal(HTMLTableSectionElement, tfoot.constructor);
- });
-
- test('rows', function() {
- var table = createTable();
- var thead = table.querySelector('thead');
- assert.instanceOf(thead.rows, HTMLCollection);
- assert.equal(thead.rows.length, 2);
-
- var tbody = table.querySelector('tbody');
- assert.instanceOf(tbody.rows, HTMLCollection);
- assert.equal(tbody.rows.length, 2);
-
- var tfoot = table.querySelector('tfoot');
- assert.instanceOf(tfoot.rows, HTMLCollection);
- assert.equal(tfoot.rows.length, 2);
- });
-
- test('insertRow', function() {
- var table = createTable();
- var thead = table.querySelector('thead');
- var tr = thead.insertRow(1);
- assert.instanceOf(tr, HTMLTableRowElement);
- assert.equal(tr.localName, 'tr');
-
- var tbody = table.querySelector('tbody');
- tr = thead.insertRow(1);
- assert.instanceOf(tr, HTMLTableRowElement);
- assert.equal(tr.localName, 'tr');
-
- var tfoot = table.querySelector('tfoot');
- tr = thead.insertRow(1);
- assert.instanceOf(tr, HTMLTableRowElement);
- assert.equal(tr.localName, 'tr');
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLTemplateElement.js b/tests/ShadowDOM/js/HTMLTemplateElement.js
deleted file mode 100644
index b31bce7..0000000
--- a/tests/ShadowDOM/js/HTMLTemplateElement.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTML Template Element', function() {
-
- test('content', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var template = div.firstChild;
- var content = template.content;
-
- assert.isNull(template.firstChild);
- assert.equal(content.childNodes.length, 2);
- assert.equal(content.firstChild.tagName, 'A');
- assert.equal(content.lastChild.tagName, 'B');
- });
-
- test('document', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var templateA = div.firstChild;
- var templateB= div.lastChild;
- var contentA = templateA.content;
- var contentB = templateB.content;
-
- assert.notEqual(templateA.ownerDocument, contentB.ownerDocument);
- assert.equal(contentA.ownerDocument, contentB.ownerDocument);
- });
-
- test('get innerHTML', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var template = div.firstChild;
-
- assert.equal(template.innerHTML, '');
-
- assert.equal(div.innerHTML, '');
- });
-
- test('get outerHTML', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var template = div.firstChild;
-
- assert.equal(template.outerHTML, '');
- assert.equal(div.outerHTML,
- '
');
- });
-
- test('importNode', function() {
- var doc2 = document.implementation.createHTMLDocument('');
- var div = doc2.createElement('div');
- div.innerHTML = '';
- var template = div.firstChild;
-
- var clone = document.importNode(template, true);
- assert.equal(clone.outerHTML, '');
-
- clone = document.importNode(div, true);
- assert.equal(clone.outerHTML,
- '
');
- });
-
- test('instanceOf', function() {
- assert.instanceOf(document.createElement('template'), HTMLTemplateElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLTemplateElement,
- document.createElement('template').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/HTMLTextAreaElement.js b/tests/ShadowDOM/js/HTMLTextAreaElement.js
deleted file mode 100644
index c37fb49..0000000
--- a/tests/ShadowDOM/js/HTMLTextAreaElement.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('HTMLTextAreaElement', function() {
-
- test('form', function() {
- var form = document.createElement('form');
- var textArea = document.createElement('textarea');
- form.appendChild(textArea);
- assert.equal(textArea.form, form);
- });
-
- test('instanceof', function() {
- assert.instanceOf(document.createElement('textarea'), HTMLTextAreaElement);
- });
-
- test('constructor', function() {
- assert.equal(HTMLTextAreaElement,
- document.createElement('textarea').constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver.js b/tests/ShadowDOM/js/MutationObserver.js
deleted file mode 100644
index 5609bdd..0000000
--- a/tests/ShadowDOM/js/MutationObserver.js
+++ /dev/null
@@ -1,299 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var addedNodes = [], removedNodes = [];
- var div;
-
- function newValue() {
- return Date.now();
- }
-
- setup(function() {
- addedNodes = [];
- removedNodes = [];
- });
-
- teardown(function() {
- addedNodes = undefined;
- removedNodes = undefined;
- if (div) {
- if (div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- }
- });
-
- function mergeRecords(records) {
- records.forEach(function(record) {
- if (record.addedNodes)
- addedNodes.push.apply(addedNodes, record.addedNodes);
- if (record.removedNodes)
- removedNodes.push.apply(removedNodes, record.removedNodes);
- });
- }
-
- test('target', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- var div = document.createElement('div');
-
- var mo = new MutationObserver(function(records, observer) {
- assert.equal(this, mo);
- assert.equal(observer, mo);
- assert.equal(records[0].type, 'attributes');
- assert.equal(records[0].target, div);
- mo.disconnect();
- done();
- });
- mo.observe(div, {
- attributes: true
- });
- div.setAttribute('a', newValue());
- });
-
- test('addedNodes', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
-
- var mo = new MutationObserver(function(records, observer) {
- mergeRecords(records);
- assert.equal(records[0].type, 'childList');
- assert.equal(records[0].target, div);
- assert.equal(addedNodes.length, 2);
- assert.equal(addedNodes[0], a);
- assert.equal(addedNodes[1], b);
- mo.disconnect();
- done();
- });
- mo.observe(div, {
- childList: true
- });
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
- });
-
- test('addedNodes siblings', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
-
- var mo = new MutationObserver(function(records, observer) {
- mergeRecords(records);
- assert.equal(records.length, 1);
- assert.equal(records[0].type, 'childList');
- assert.equal(records[0].target, div);
- assert.equal(addedNodes.length, 1);
- assert.equal(addedNodes[0], c);
- assert.equal(records[0].previousSibling, a);
- assert.equal(records[0].nextSibling, b);
- mo.disconnect();
- done();
- });
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
-
- mo.observe(div, {
- childList: true
- });
-
- var c = document.createElement('c');
- div.insertBefore(c, b);
-
- });
-
- test('removedNodes', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
-
- var mo = new MutationObserver(function(records, observer) {
- mergeRecords(records);
- assert.equal(records[0].type, 'childList');
- assert.equal(records[0].target, div);
- assert.equal(addedNodes.length, 2);
- assert.equal(addedNodes[0], c);
- assert.equal(addedNodes[1], d);
- assert.equal(removedNodes.length, 2);
- // The ordering of the removed nodes is different in IE11.
- if (removedNodes[0] === a) {
- assert.equal(removedNodes[1], b);
- } else {
- assert.equal(removedNodes[0], b);
- assert.equal(removedNodes[1], a);
- }
- mo.disconnect();
- done();
- });
-
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
-
- mo.observe(div, {
- childList: true
- });
-
- div.innerHTML = '';
- var c = div.firstChild;
- var d = div.lastChild;
- });
-
- test('removedNodes siblings', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
-
- var mo = new MutationObserver(function(records, observer) {
- mergeRecords(records);
- assert.equal(records.length, 1);
- assert.equal(records[0].type, 'childList');
- assert.equal(removedNodes.length, 1);
- assert.equal(records[0].previousSibling, a);
- assert.equal(records[0].nextSibling, c);
- mo.disconnect();
- done();
- });
-
- div.innerHTML = '';
- var a = div.firstChild;
- var b = a.nextSibling;
- var c = div.lastChild;
-
- mo.observe(div, {
- childList: true
- });
-
- div.removeChild(b);
- });
-
- test('observe document', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- var mo = new MutationObserver(function(records, observer) {
- assert.equal(this, mo);
- assert.equal(observer, mo);
- assert.equal(records[0].type, 'attributes');
- assert.equal(records[0].target, wrap(document).body);
- mo.disconnect();
- done();
- });
- mo.observe(document, {
- attributes: true,
- subtree: true
- });
-
- wrap(document).body.setAttribute('a', newValue());
- });
-
- test('observe document.body', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- var mo = new MutationObserver(function(records, observer) {
- assert.equal(this, mo);
- assert.equal(observer, mo);
- assert.equal(records[0].type, 'attributes');
- assert.equal(records[0].target, wrap(document).body);
- mo.disconnect();
- done();
- });
- mo.observe(document.body, {
- attributes: true
- });
-
- wrap(document.body).setAttribute('a', newValue());
- });
-
- test('observe document.head', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- var mo = new MutationObserver(function(records, observer) {
- assert.equal(this, mo);
- assert.equal(observer, mo);
- assert.equal(records[0].type, 'attributes');
- assert.equal(records[0].target, wrap(document).head);
- mo.disconnect();
- done();
- });
- mo.observe(document.head, {
- attributes: true
- });
-
- wrap(document.head).setAttribute('a', newValue());
- });
-
- test('observe text node', function(done) {
- if (!window.MutationObserver) {
- done();
- return;
- }
-
- div = document.body.appendChild(document.createElement('div'));
- var a = document.createTextNode('');
- div.appendChild(a);
-
- var mo = new MutationObserver(function(records, observer) {
- mergeRecords(records);
- assert.equal(this, mo);
- assert.equal(observer, mo);
- assert.equal(records[0].type, 'childList');
- assert.equal(records[0].target, div);
-
- // IE11 is broken and reports the text node being removed twice.
- if (!/Trident/.test(navigator.userAgent))
- assert.equal(removedNodes.length, 1);
- assert.equal(removedNodes[0], a);
- done();
- });
- mo.observe(div, {childList: true});
-
- div.removeChild(a);
- });
-
- test('instanceof', function() {
- var mo = new MutationObserver(function(records, observer) {});
- assert.instanceOf(mo, MutationObserver);
- });
-
- test('constructor', function() {
- var mo = new MutationObserver(function(records, observer) {});
- assert.equal(MutationObserver, mo.constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/attributes.js b/tests/ShadowDOM/js/MutationObserver/attributes.js
deleted file mode 100644
index 9e639ea..0000000
--- a/tests/ShadowDOM/js/MutationObserver/attributes.js
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('attributes', function() {
-
- test('attr', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true
- });
- div.setAttribute('a', 'A');
- div.setAttribute('a', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
- });
-
- test('attr with oldValue', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- attributeOldValue: true
- });
- div.setAttribute('a', 'A');
- div.setAttribute('a', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null,
- oldValue: null
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null,
- oldValue: 'A'
- });
- });
-
- test('attr change in subtree should not genereate a record', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true
- });
- child.setAttribute('a', 'A');
- child.setAttribute('a', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 0);
- });
-
- test('attr change, subtree', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- subtree: true
- });
- child.setAttribute('a', 'A');
- child.setAttribute('a', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'a'
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: child,
- attributeName: 'a'
- });
- });
-
-
- test('multiple observers on same target', function() {
- var div = document.createElement('div');
- var observer1 = new MutationObserver(function() {});
- observer1.observe(div, {
- attributes: true,
- attributeOldValue: true
- });
- var observer2 = new MutationObserver(function() {});
- observer2.observe(div, {
- attributes: true,
- attributeFilter: ['b']
- });
-
- div.setAttribute('a', 'A');
- div.setAttribute('a', 'A2');
- div.setAttribute('b', 'B');
-
- var records = observer1.takeRecords();
- assert.equal(records.length, 3);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a'
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- oldValue: 'A'
- });
- expectMutationRecord(records[2], {
- type: 'attributes',
- target: div,
- attributeName: 'b'
- });
-
- records = observer2.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'b'
- });
- });
-
- test('observer observes on different target', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(child, {
- attributes: true
- });
- observer.observe(div, {
- attributes: true,
- subtree: true,
- attributeOldValue: true
- });
-
- child.setAttribute('a', 'A');
- child.setAttribute('a', 'A2');
- child.setAttribute('b', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 3);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'a'
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: child,
- attributeName: 'a',
- oldValue: 'A'
- });
- expectMutationRecord(records[2], {
- type: 'attributes',
- target: child,
- attributeName: 'b'
- });
- });
-
- test('observing on the same node should update the options', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- attributeFilter: ['a']
- });
- observer.observe(div, {
- attributes: true,
- attributeFilter: ['b']
- });
-
- div.setAttribute('a', 'A');
- div.setAttribute('b', 'B');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'b'
- });
- });
-
- test('disconnect should stop all events and empty the records', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- });
-
- div.setAttribute('a', 'A');
-
- observer.disconnect();
- var records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- div.setAttribute('b', 'B');
-
- records = observer.takeRecords();
- assert.equal(records.length, 0);
- });
-
- test('disconnect should not affect other observers', function() {
- var div = document.createElement('div');
- var observer1 = new MutationObserver(function() {});
- observer1.observe(div, {
- attributes: true,
- });
- var observer2 = new MutationObserver(function() {});
- observer2.observe(div, {
- attributes: true,
- });
-
- div.setAttribute('a', 'A');
-
- observer1.disconnect();
- var records1 = observer1.takeRecords();
- assert.equal(records1.length, 0);
-
- var records2 = observer2.takeRecords();
- assert.equal(records2.length, 1);
- expectMutationRecord(records2[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a'
- });
-
- div.setAttribute('b', 'B');
-
- records1 = observer1.takeRecords();
- assert.equal(records1.length, 0);
-
- records2 = observer2.takeRecords();
- assert.equal(records2.length, 1);
- expectMutationRecord(records2[0], {
- type: 'attributes',
- target: div,
- attributeName: 'b'
- });
- });
-
- test('should notify changes by target\'s classList property', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- attributeOldValue: true
- });
- div.classList.add('A');
- div.classList.add('A'); //< Should be ignored
- div.classList.remove('A');
- div.classList.remove('A'); //< Should be ignored
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'class',
- attributeNamespace: null,
- oldValue: null
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: div,
- attributeName: 'class',
- attributeNamespace: null,
- oldValue: 'A'
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/callback.js b/tests/ShadowDOM/js/MutationObserver/callback.js
deleted file mode 100644
index 6c25621..0000000
--- a/tests/ShadowDOM/js/MutationObserver/callback.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('callback', function() {
-
- test('One observer, two attribute changes', function(done) {
- var div = document.createElement('div');
- var observer = new MutationObserver(function(records) {
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
- expectMutationRecord(records[1], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
-
- done();
- });
-
- observer.observe(div, {
- attributes: true
- });
-
- div.setAttribute('a', 'A');
- div.setAttribute('a', 'B');
- });
-
- test('nested changes', function(done) {
- var div = document.createElement('div');
- var i = 0;
- var observer = new MutationObserver(function(records) {
- assert.equal(records.length, 1);
-
- if (i === 0) {
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
- div.setAttribute('b', 'B');
- i++;
- } else {
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'b',
- attributeNamespace: null
- });
-
- done();
- }
- });
-
- observer.observe(div, {
- attributes: true
- });
-
- div.setAttribute('a', 'A');
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/characterData.js b/tests/ShadowDOM/js/MutationObserver/characterData.js
deleted file mode 100644
index 317c1e6..0000000
--- a/tests/ShadowDOM/js/MutationObserver/characterData.js
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('characterData', function() {
-
- test('characterData', function() {
- var text = document.createTextNode('abc');
- var observer = new MutationObserver(function() {});
- observer.observe(text, {
- characterData: true
- });
- text.data = 'def';
- text.data = 'ghi';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: text
- });
- expectMutationRecord(records[1], {
- type: 'characterData',
- target: text
- });
- });
-
- test('characterData with old value', function() {
- var text = document.createTextNode('abc');
- var observer = new MutationObserver(function() {});
- observer.observe(text, {
- characterData: true,
- characterDataOldValue: true
- });
- text.data = 'def';
- text.data = 'ghi';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: text,
- oldValue: 'abc'
- });
- expectMutationRecord(records[1], {
- type: 'characterData',
- target: text,
- oldValue: 'def'
- });
- });
-
- test('characterData change in subtree should not generate a record',
- function() {
- var div = document.createElement('div');
- var text = div.appendChild(document.createTextNode('abc'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- characterData: true
- });
- text.data = 'def';
- text.data = 'ghi';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 0);
- });
-
- test('characterData change in subtree',
- function() {
- var div = document.createElement('div');
- var text = div.appendChild(document.createTextNode('abc'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- characterData: true,
- subtree: true
- });
- text.data = 'def';
- text.data = 'ghi';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: text
- });
- expectMutationRecord(records[1], {
- type: 'characterData',
- target: text
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/childList.js b/tests/ShadowDOM/js/MutationObserver/childList.js
deleted file mode 100644
index 13e69aa..0000000
--- a/tests/ShadowDOM/js/MutationObserver/childList.js
+++ /dev/null
@@ -1,799 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
- 'use strict';
-
- suite('childList', function() {
-
- var NodeList = ShadowDOMPolyfill.wrappers.NodeList;
-
- function makeNodeList(/* ...args */) {
- var nodeList = new NodeList;
- for (var i = 0; i < arguments.length; i++) {
- nodeList[i] = arguments[i];
- }
- nodeList.length = i;
- return nodeList;
- }
-
- test('appendChild', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
- var a = document.createElement('a');
- var b = document.createElement('b');
-
- div.appendChild(a);
- div.appendChild(b);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: [a]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: div,
- addedNodes: [b],
- previousSibling: a
- });
- });
-
- test('insertBefore', function() {
- var div = document.createElement('div');
- var a = document.createElement('a');
- var b = document.createElement('b');
- var c = document.createElement('c');
- div.appendChild(a);
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.insertBefore(b, a);
- div.insertBefore(c, a);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: [b],
- nextSibling: a
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: div,
- addedNodes: [c],
- nextSibling: a,
- previousSibling: b
- });
- });
-
- test('replaceChild', function() {
- var div = document.createElement('div');
- var a = document.createElement('a');
- var b = document.createElement('b');
- div.appendChild(a);
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.replaceChild(b, a);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: [b],
- removedNodes: [a]
- });
- });
-
- test('removeChild', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createElement('a'));
- var b = div.appendChild(document.createElement('b'));
- var c = div.appendChild(document.createElement('c'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.removeChild(b);
- div.removeChild(a);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- removedNodes: [b],
- nextSibling: c,
- previousSibling: a
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: div,
- removedNodes: [a],
- nextSibling: c
- });
- });
-
- test('Direct children', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
- var a = document.createElement('a');
- var b = document.createElement('b');
-
- div.appendChild(a);
- div.insertBefore(b, a);
- div.removeChild(b);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 3);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: [a]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: div,
- nextSibling: a,
- addedNodes: [b]
- });
-
- expectMutationRecord(records[2], {
- type: 'childList',
- target: div,
- nextSibling: a,
- removedNodes: [b]
- });
- });
-
- test('subtree', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var observer = new MutationObserver(function() {});
- observer.observe(child, {
- childList: true
- });
- var a = document.createTextNode('a');
- var b = document.createTextNode('b');
-
- child.appendChild(a);
- child.insertBefore(b, a);
- child.removeChild(b);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 3);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: child,
- addedNodes: [a]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: child,
- nextSibling: a,
- addedNodes: [b]
- });
-
- expectMutationRecord(records[2], {
- type: 'childList',
- target: child,
- nextSibling: a,
- removedNodes: [b]
- });
- });
-
- test('both direct and subtree', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true,
- subtree: true
- });
- observer.observe(child, {
- childList: true
- });
-
- var a = document.createTextNode('a');
- var b = document.createTextNode('b');
-
- child.appendChild(a);
- div.appendChild(b);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: child,
- addedNodes: [a]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: div,
- addedNodes: [b],
- previousSibling: child
- });
- });
-
- test('Append multiple at once at the end', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- var df = document.createDocumentFragment();
- var b = df.appendChild(document.createTextNode('b'));
- var c = df.appendChild(document.createTextNode('c'));
- var d = df.appendChild(document.createTextNode('d'));
-
- div.appendChild(df);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(b, c, d),
- removedNodes: makeNodeList(),
- previousSibling: a,
- nextSibling: null
- });
- });
-
- test('Append multiple at once at the front', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- var df = document.createDocumentFragment();
- var b = df.appendChild(document.createTextNode('b'));
- var c = df.appendChild(document.createTextNode('c'));
- var d = df.appendChild(document.createTextNode('d'));
-
- div.insertBefore(df, a);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(b, c, d),
- removedNodes: makeNodeList(),
- previousSibling: null,
- nextSibling: a
- });
- });
-
- test('Append multiple at once in the middle', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
- var b = div.appendChild(document.createTextNode('b'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- var df = document.createDocumentFragment();
- var c = df.appendChild(document.createTextNode('c'));
- var d = df.appendChild(document.createTextNode('d'));
-
- div.insertBefore(df, b);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(c, d),
- removedNodes: makeNodeList(),
- previousSibling: a,
- nextSibling: b
- });
- });
-
- test('Remove all children using innerHTML', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
- var b = div.appendChild(document.createTextNode('b'));
- var c = div.appendChild(document.createTextNode('c'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.innerHTML = '';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(),
- removedNodes: makeNodeList(a, b, c),
- previousSibling: null,
- nextSibling: null
- });
- });
-
- test('Replace all children using innerHTML', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
- var b = div.appendChild(document.createTextNode('b'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.innerHTML = '';
- var c = div.firstChild;
- var d = div.lastChild;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(c, d),
- removedNodes: makeNodeList(a, b),
- previousSibling: null,
- nextSibling: null
- });
- });
-
- test('Remove all children using textContent', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
- var b = div.appendChild(document.createTextNode('b'));
- var c = div.appendChild(document.createTextNode('c'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.textContent = '';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(),
- removedNodes: makeNodeList(a, b, c),
- previousSibling: null,
- nextSibling: null
- });
- });
-
- test('Replace all children using textContent', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createTextNode('a'));
- var b = div.appendChild(document.createTextNode('b'));
-
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true
- });
-
- div.textContent = 'text';
- var text = div.firstChild;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- addedNodes: makeNodeList(text),
- removedNodes: makeNodeList(a, b),
- previousSibling: null,
- nextSibling: null
- });
- });
-
- test('appendChild removal', function() {
- var a = document.createElement('a');
- var b = document.createElement('b');
- var c = document.createElement('c');
-
- a.appendChild(c);
-
- var observerA = new MutationObserver(function() {});
- observerA.observe(a, {
- childList: true
- });
-
- var observerB = new MutationObserver(function() {});
- observerB.observe(b, {
- childList: true
- });
-
- b.appendChild(c);
-
- var recordsA = observerA.takeRecords();
-
- assert.equal(recordsA.length, 1);
- expectMutationRecord(recordsA[0], {
- type: 'childList',
- target: a,
- removedNodes: [c]
- });
-
- var recordsB = observerB.takeRecords();
- assert.equal(recordsB.length, 1);
- expectMutationRecord(recordsB[0], {
- type: 'childList',
- target: b,
- addedNodes: [c]
- });
- });
-
- test('insertBefore removal', function() {
- var a = document.createElement('a');
- var b = document.createElement('b');
- var c = document.createElement('c');
- var d = document.createElement('d');
- var e = document.createElement('e');
-
- a.appendChild(c);
- a.appendChild(d);
- b.appendChild(e);
-
- var observerA = new MutationObserver(function() {});
- observerA.observe(a, {
- childList: true
- });
-
- var observerB = new MutationObserver(function() {});
- observerB.observe(b, {
- childList: true
- });
-
- b.insertBefore(d, e);
-
- var recordsA = observerA.takeRecords();
-
- assert.equal(recordsA.length, 1);
- expectMutationRecord(recordsA[0], {
- type: 'childList',
- target: a,
- removedNodes: [d],
- previousSibling: c
- });
-
- var recordsB = observerB.takeRecords();
- assert.equal(recordsB.length, 1);
- expectMutationRecord(recordsB[0], {
- type: 'childList',
- target: b,
- addedNodes: [d],
- nextSibling: e
- });
- });
-
- test('insertBefore removal document fragment', function() {
- var df = document.createDocumentFragment();
- var a = df.appendChild(document.createElement('a'));
- var b = df.appendChild(document.createElement('b'));
- var c = df.appendChild(document.createElement('c'));
-
- var d = document.createElement('d');
- var e = d.appendChild(document.createElement('e'));
- var f = d.appendChild(document.createElement('f'));
-
- var observerDf = new MutationObserver(function() {});
- observerDf.observe(df, {
- childList: true
- });
-
- var observerD = new MutationObserver(function() {});
- observerD.observe(d, {
- childList: true
- });
-
- d.insertBefore(df, f);
-
- var recordsDf = observerDf.takeRecords();
-
- assert.equal(recordsDf.length, 1);
- expectMutationRecord(recordsDf[0], {
- type: 'childList',
- target: df,
- removedNodes: [a, b, c]
- });
-
- var recordsD = observerD.takeRecords();
- assert.equal(recordsD.length, 1);
- expectMutationRecord(recordsD[0], {
- type: 'childList',
- target: d,
- addedNodes: [a, b, c],
- previousSibling: e,
- nextSibling: f
- });
- });
-
-
- test('insertBefore removal document fragment (with shadow roots)', function() {
- var df = document.createDocumentFragment();
- var a = df.appendChild(document.createElement('a'));
- var b = df.appendChild(document.createElement('b'));
- var c = df.appendChild(document.createElement('c'));
-
- var d = document.createElement('d');
- var sr = d.createShadowRoot();
- var e = sr.appendChild(document.createElement('e'));
- var f = sr.appendChild(document.createElement('f'));
-
- var observerDf = new MutationObserver(function() {});
- observerDf.observe(df, {
- childList: true
- });
-
- var observerSr = new MutationObserver(function() {});
- observerSr.observe(sr, {
- childList: true
- });
-
- sr.insertBefore(df, f);
-
- var recordsDf = observerDf.takeRecords();
-
- assert.equal(recordsDf.length, 1);
- expectMutationRecord(recordsDf[0], {
- type: 'childList',
- target: df,
- removedNodes: [a, b, c]
- });
-
- var recordsSr = observerSr.takeRecords();
- assert.equal(recordsSr.length, 1);
- expectMutationRecord(recordsSr[0], {
- type: 'childList',
- target: sr,
- addedNodes: [a, b, c],
- previousSibling: e,
- nextSibling: f
- });
- });
-
- test('Check old siblings', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = a.lastChild;
-
- var d = document.createElement('d');
- d.innerHTML = '';
- var e = d.firstChild;
- var f = e.nextSibling;
- var g = d.lastChild;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- var observer2 = new MutationObserver(function() {});
- observer2.observe(d, {
- childList: true
- });
-
- a.insertBefore(f, c);
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [f],
- previousSibling: b,
- nextSibling: c
- });
-
- records = observer2.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: d,
- removedNodes: [f],
- previousSibling: e,
- nextSibling: g
- });
- });
-
- test('insertAdjacentHTML beforebegin', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = a.lastChild;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- c.insertAdjacentHTML('beforebegin', '');
-
- assert.equal(a.innerHTML, '');
- var d = b.nextSibling;
- var e = d.nextSibling;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [d, e],
- previousSibling: b,
- nextSibling: c
- });
- });
-
- test('insertAdjacentHTML afterbegin', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = a.lastChild;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- a.insertAdjacentHTML('afterbegin', '');
-
- assert.equal(a.innerHTML, '');
- var d = a.firstChild;
- var e = d.nextSibling;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [d, e],
- previousSibling: null,
- nextSibling: b
- });
- });
-
- test('insertAdjacentHTML beforeend', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = a.lastChild;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- a.insertAdjacentHTML('beforeend', '');
-
- assert.equal(a.innerHTML, '');
- var d = c.nextSibling;
- var e = d.nextSibling;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [d, e],
- previousSibling: c,
- nextSibling: null
- });
- });
-
- test('insertAdjacentHTML afterend', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = a.lastChild;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- b.insertAdjacentHTML('afterend', '');
-
- assert.equal(a.innerHTML, '');
- var d = b.nextSibling;
- var e = d.nextSibling;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [d, e],
- previousSibling: b,
- nextSibling: c
- });
- });
-
- test('outerHTML', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var c = b.nextSibling;
- var d = a.lastChild;
-
- var sr = a.createShadowRoot();
- a.offsetHeight;
-
- var observer = new MutationObserver(function() {});
- observer.observe(a, {
- childList: true
- });
-
- c.outerHTML = '';
- assert.equal(a.innerHTML, '');
- var e = b.nextSibling;
- var f = e.nextSibling;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: a,
- addedNodes: [e, f],
- removedNodes: [c],
- previousSibling: b,
- nextSibling: d
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/mixed.js b/tests/ShadowDOM/js/MutationObserver/mixed.js
deleted file mode 100644
index 830c0d2..0000000
--- a/tests/ShadowDOM/js/MutationObserver/mixed.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('mixed', function() {
-
- test('attr and characterData', function() {
- var div = document.createElement('div');
- var text = div.appendChild(document.createTextNode('text'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- characterData: true,
- subtree: true
- });
- div.setAttribute('a', 'A');
- div.firstChild.data = 'changed';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: div,
- attributeName: 'a',
- attributeNamespace: null
- });
- expectMutationRecord(records[1], {
- type: 'characterData',
- target: div.firstChild
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/options.js b/tests/ShadowDOM/js/MutationObserver/options.js
deleted file mode 100644
index be26821..0000000
--- a/tests/ShadowDOM/js/MutationObserver/options.js
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('options', function() {
-
- test('attributeOldValue and attributes', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
-
- assert.throws(function() {
- observer.observe(div, {
- attributeOldValue: true,
- attributes: false
- });
- }, TypeError);
-
- observer.observe(div, {
- attributeOldValue: true,
- });
-
- observer.observe(div, {
- attributeOldValue: false,
- attributes: false
- });
-
- observer.observe(div, {
- attributeOldValue: false,
- attributes: true
- });
-
- observer.observe(div, {
- attributeOldValue: true,
- attributes: true
- });
- });
-
- test('attributeFilter and attributes', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
-
- assert.throws(function() {
- observer.observe(div, {
- attributeFilter: ['name'],
- attributes: false
- });
- }, TypeError);
-
- observer.observe(div, {
- attributeFilter: ['name'],
- });
-
- assert.throws(function() {
- observer.observe(div, {
- attributeFilter: null,
- });
- }, TypeError);
-
- observer.observe(div, {
- attributeFilter: ['name'],
- attributes: true
- });
-
- observer.observe(div, {
- attributes: false
- });
-
- observer.observe(div, {
- attributes: true
- });
- });
-
- test('characterDataOldValue and characterData', function() {
- var div = document.createElement('div');
- var observer = new MutationObserver(function() {});
-
- assert.throws(function() {
- observer.observe(div, {
- characterDataOldValue: true,
- characterData: false
- });
- }, TypeError);
-
- observer.observe(div, {
- characterDataOldValue: true
- });
-
- observer.observe(div, {
- characterDataOldValue: false,
- characterData: false
- });
-
- observer.observe(div, {
- characterDataOldValue: false,
- characterData: true
- });
-
- observer.observe(div, {
- characterDataOldValue: true,
- characterData: true
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/shadow-root.js b/tests/ShadowDOM/js/MutationObserver/shadow-root.js
deleted file mode 100644
index 33e32f3..0000000
--- a/tests/ShadowDOM/js/MutationObserver/shadow-root.js
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('Shadow Root', function() {
-
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- test('Make no notifications due to render', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var sr = a.createShadowRoot();
- sr.innerHTML = '';
-
- var observer = new MutationObserver(function() {});
-
- observer.observe(a, {
- childList: true,
- attributes: true,
- characterData: true,
- subtree: true
- });
- observer.observe(sr, {
- childList: true,
- attributes: true,
- characterData: true,
- subtree: true
- });
-
- a.offsetHeight;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- assert.equal(unwrap(a).outerHTML, '');
- });
-
- test('Observe ShadowRoot', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var sr = a.createShadowRoot();
- sr.innerHTML = '';
- var c = sr.firstChild;
- var d = c.nextSibling;
- var content = d.firstChild;
-
- var observer = new MutationObserver(function() {});
-
- observer.observe(sr, {
- childList: true,
- subtree: true
- });
-
- a.offsetHeight;
-
- var records = observer.takeRecords();
- assert.equal(records.length, 0);
- assert.equal(unwrap(a).outerHTML, '');
-
- var e = document.createElement('e');
- e.innerHTML = '';
- var f = e.firstChild;
- var g = f.nextSibling
- var h = e.lastChild;
-
- var observer2 = new MutationObserver(function() {});
- observer2.observe(e, {
- childList: true,
- subtree: true
- });
-
- d.insertBefore(g, content);
-
- assert.equal(unwrap(a).outerHTML, '');
- a.offsetHeight;
- assert.equal(unwrap(a).outerHTML, '');
-
- records = observer.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: d,
- addedNodes: [g],
- previousSibling: null,
- nextSibling: content
- });
-
- records = observer2.takeRecords();
- assert.equal(records.length, 1);
- expectMutationRecord(records[0], {
- type: 'childList',
- target: e,
- removedNodes: [g],
- previousSibling: f,
- nextSibling: h
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/MutationObserver/transient.js b/tests/ShadowDOM/js/MutationObserver/transient.js
deleted file mode 100644
index af3198d..0000000
--- a/tests/ShadowDOM/js/MutationObserver/transient.js
+++ /dev/null
@@ -1,310 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('MutationObserver', function() {
-
- suite('transient', function() {
-
- test('attr', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- attributes: true,
- subtree: true
- });
- div.removeChild(child);
- child.setAttribute('a', 'A');
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'a',
- attributeNamespace: null
- });
-
- child.setAttribute('b', 'B');
-
- records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'b',
- attributeNamespace: null
- });
- });
-
- test('attr callback', function(cont) {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var i = 0;
- var observer = new MutationObserver(function(records) {
- i++;
- if (i > 1)
- expect().fail();
-
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'a',
- attributeNamespace: null
- });
-
- // The transient observers are removed before the callback is called.
- child.setAttribute('b', 'B');
- records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- cont();
- });
-
- observer.observe(div, {
- attributes: true,
- subtree: true
- });
-
- div.removeChild(child);
- child.setAttribute('a', 'A');
- });
-
- test('attr, make sure transient gets removed', function(cont) {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var i = 0;
- var observer = new MutationObserver(function(records) {
- i++;
- if (i > 1)
- expect().fail();
-
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'a',
- attributeNamespace: null
- });
-
- step2();
- });
-
- observer.observe(div, {
- attributes: true,
- subtree: true
- });
-
- div.removeChild(child);
- child.setAttribute('a', 'A');
-
- function step2() {
- var div2 = document.createElement('div');
- var observer2 = new MutationObserver(function(records) {
- i++;
- if (i > 2)
- expect().fail();
-
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'attributes',
- target: child,
- attributeName: 'b',
- attributeNamespace: null
- });
-
- cont();
- });
-
- observer2.observe(div2, {
- attributes: true,
- subtree: true,
- });
-
- div2.appendChild(child);
- child.setAttribute('b', 'B');
- }
- });
-
- test('characterData', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createTextNode('text'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- characterData: true,
- subtree: true
- });
- div.removeChild(child);
- child.data = 'changed';
-
- var records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: child
- });
-
- child.data += ' again';
-
- records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: child
- });
- });
-
- test('characterData callback', function(cont) {
- var div = document.createElement('div');
- var child = div.appendChild(document.createTextNode('text'));
- var i = 0;
- var observer = new MutationObserver(function(records) {
- i++;
- if (i > 1)
- expect().fail();
-
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'characterData',
- target: child
- });
-
- // The transient observers are removed before the callback is called.
- child.data += ' again';
- records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- cont();
- });
- observer.observe(div, {
- characterData: true,
- subtree: true
- });
- div.removeChild(child);
- child.data = 'changed';
- });
-
- test('childList', function() {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- childList: true,
- subtree: true
- });
- div.removeChild(child);
- var grandChild = child.appendChild(document.createElement('span'));
-
- var records = observer.takeRecords();
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- removedNodes: [child]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: child,
- addedNodes: [grandChild]
- });
-
- child.removeChild(grandChild);
-
- records = observer.takeRecords();
- assert.equal(records.length, 1);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: child,
- removedNodes: [grandChild]
- });
- });
-
- test('childList callback', function(cont) {
- var div = document.createElement('div');
- var child = div.appendChild(document.createElement('div'));
- var i = 0;
- var observer = new MutationObserver(function(records) {
- i++;
- if (i > 1)
- expect().fail();
-
- assert.equal(records.length, 2);
-
- expectMutationRecord(records[0], {
- type: 'childList',
- target: div,
- removedNodes: [child]
- });
-
- expectMutationRecord(records[1], {
- type: 'childList',
- target: child,
- addedNodes: [grandChild]
- });
-
- // The transient observers are removed before the callback is called.
- child.removeChild(grandChild);
-
- records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- cont();
- });
- observer.observe(div, {
- childList: true,
- subtree: true
- });
- div.removeChild(child);
- var grandChild = child.appendChild(document.createElement('span'));
- });
-
- // https://dom.spec.whatwg.org/#notify-mutation-observers
- test('removed at end of microtask', function(done) {
- var div = document.createElement('div');
- var child = div.appendChild(document.createTextNode('text'));
- var observer = new MutationObserver(function() {});
- observer.observe(div, {
- characterData: true,
- subtree: true
- });
- div.removeChild(child);
-
- records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- // Run after all other end-of-microtask things, like observers, have
- // had their chance to run. Use `setTimeout(4)` to keep the test isolated
- // from details of the MutationObserver system and to have it run late
- // enough on browsers without true microtasks.
- setTimeout(function() {
- child.data = 'changed';
-
- records = observer.takeRecords();
- assert.equal(records.length, 0);
-
- done();
- }, 4);
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/Node.js b/tests/ShadowDOM/js/Node.js
deleted file mode 100644
index 2d0e7a8..0000000
--- a/tests/ShadowDOM/js/Node.js
+++ /dev/null
@@ -1,469 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Node', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- var DOCUMENT_POSITION_DISCONNECTED = Node.DOCUMENT_POSITION_DISCONNECTED;
- var DOCUMENT_POSITION_PRECEDING = Node.DOCUMENT_POSITION_PRECEDING;
- var DOCUMENT_POSITION_FOLLOWING = Node.DOCUMENT_POSITION_FOLLOWING;
- var DOCUMENT_POSITION_CONTAINS = Node.DOCUMENT_POSITION_CONTAINS;
- var DOCUMENT_POSITION_CONTAINED_BY = Node.DOCUMENT_POSITION_CONTAINED_BY;
- var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
-
- suite('compareDocumentPosition', function() {
-
- test('between wrappers', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var a = div.firstChild;
- var b = a.firstChild;
- var c = a.lastChild;
-
- assert.equal(div.compareDocumentPosition(div), 0);
- assert.equal(div.compareDocumentPosition(a),
- DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING);
- assert.equal(div.compareDocumentPosition(b),
- DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING);
- assert.equal(div.compareDocumentPosition(c),
- DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING);
-
- assert.equal(a.compareDocumentPosition(div),
- DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
- assert.equal(a.compareDocumentPosition(a), 0);
- assert.equal(a.compareDocumentPosition(b),
- DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING);
- assert.equal(a.compareDocumentPosition(c),
- DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING);
-
- assert.equal(b.compareDocumentPosition(div),
- DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
- assert.equal(b.compareDocumentPosition(a),
- DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
- assert.equal(b.compareDocumentPosition(b), 0);
- assert.equal(b.compareDocumentPosition(c),
- DOCUMENT_POSITION_FOLLOWING);
-
- assert.equal(c.compareDocumentPosition(div),
- DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
- assert.equal(c.compareDocumentPosition(a),
- DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
- assert.equal(c.compareDocumentPosition(b),
- DOCUMENT_POSITION_PRECEDING);
- assert.equal(c.compareDocumentPosition(c), 0);
-
- // WebKit uses DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC.
- assert.notEqual(document.compareDocumentPosition(div) &
- DOCUMENT_POSITION_DISCONNECTED, 0)
- });
-
- var doc = wrap(document);
- test('with document', function() {
- assert.equal(doc.compareDocumentPosition(doc), 0);
- assert.equal(doc.compareDocumentPosition(document), 0);
- assert.equal(document.compareDocumentPosition(document), 0);
- assert.equal(document.compareDocumentPosition(doc), 0);
- });
- test('with document.body', function() {
- assert.equal(doc.body.compareDocumentPosition(doc.body), 0);
- assert.equal(doc.body.compareDocumentPosition(document.body), 0);
- assert.equal(document.body.compareDocumentPosition(document.body), 0);
- assert.equal(document.body.compareDocumentPosition(doc.body), 0);
- });
- test('with document.head', function() {
- assert.equal(doc.head.compareDocumentPosition(doc.head), 0);
- assert.equal(doc.head.compareDocumentPosition(document.head), 0);
- assert.equal(document.head.compareDocumentPosition(document.head), 0);
- assert.equal(document.head.compareDocumentPosition(doc.head), 0);
- });
- test('with document.documentElement', function() {
- assert.equal(doc.documentElement.compareDocumentPosition(
- doc.documentElement), 0);
- assert.equal(doc.documentElement.compareDocumentPosition(
- document.documentElement), 0);
- assert.equal(document.documentElement.compareDocumentPosition(
- document.documentElement), 0);
- assert.equal(document.documentElement.compareDocumentPosition(
- doc.documentElement), 0);
- });
- });
-
- test('ownerDocument with template and shadow root', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
-
- var content1 = div.firstChild.content;
- var host = content1.firstChild;
-
- div.innerHTML = 'hello world';
- var content2 = div.firstChild.content;
- var x = content2.firstChild;
-
- var sr = host.createShadowRoot();
- sr.appendChild(content2);
-
- assert.equal(x.parentNode, sr);
- assert.equal(x.ownerDocument, sr.ownerDocument);
- assert.equal(sr.ownerDocument, host.ownerDocument);
-
- var doc = wrap(document);
- doc.body.appendChild(host);
- assert.equal(host.ownerDocument, doc);
- assert.equal(sr.ownerDocument, doc);
- assert.equal(x.ownerDocument, doc);
-
- doc.body.removeChild(host);
- });
-
- test('ownerDocument when appending to document', function() {
- var doc1 = document.implementation.createHTMLDocument('');
- var comment = doc1.createComment('');
- doc1.appendChild(comment);
- assert.equal(doc1, comment.ownerDocument);
-
- var doc2 = document.implementation.createHTMLDocument('');
- doc2.appendChild(comment);
- assert.equal(doc2, comment.ownerDocument);
- });
-
- test('removeChild resets pointers', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
- var sr = host.createShadowRoot();
-
- host.offsetHeight;
-
- host.removeChild(a);
-
- expectStructure(a, {});
-
- var div = document.createElement('div');
- div.appendChild(a);
-
- expectStructure(div, {
- firstChild: a,
- lastChild: a
- });
-
- expectStructure(a, {
- parentNode: div
- });
- });
-
- test('replaceChild resets pointers', function() {
- var host = document.createElement('div');
- host.innerHTML = '';
- var a = host.firstChild;
- var sr = host.createShadowRoot();
-
- host.offsetHeight;
-
- var b = document.createElement('b');
-
- host.replaceChild(b, a);
-
- expectStructure(a, {});
-
- expectStructure(b, {
- parentNode: host
- });
-
- var div = document.createElement('div');
- div.appendChild(a);
-
- expectStructure(div, {
- firstChild: a,
- lastChild: a
- });
-
- expectStructure(a, {
- parentNode: div
- });
- });
-
- test('appendChild resets pointers', function() {
- var host1 = document.createElement('div');
- host1.innerHTML = '';
- var a = host1.firstChild;
- var sr1 = host1.createShadowRoot();
-
- var host2 = document.createElement('div');
- host2.innerHTML = '';
- var b = host2.firstChild;
- var sr2 = host2.createShadowRoot();
-
- host1.offsetHeight;
- host2.offsetHeight;
-
- host1.appendChild(b);
-
- expectStructure(host1, {
- firstChild: a,
- lastChild: b
- });
-
- expectStructure(a, {
- parentNode: host1,
- nextSibling: b
- });
-
- expectStructure(b, {
- parentNode: host1,
- previousSibling: a
- });
-
- expectStructure(host2, {});
- });
-
- test('hasChildNodes without a shadow root', function() {
- var div = document.createElement('div');
-
- assert.isFalse(div.hasChildNodes(), 'should be false with no children');
-
- div.innerHTML = '';
- assert.isTrue(div.hasChildNodes(), 'should be true with a single child');
-
- div.innerHTML = '
';
- assert.isTrue(div.hasChildNodes(), 'should be true with multiple children');
- });
-
- test('parentElement', function() {
- var a = document.createElement('a');
- a.textContent = 'text';
- var textNode = a.firstChild;
- assert.equal(textNode.parentElement, a);
- assert.isNull(a.parentElement);
-
- var doc = wrap(document);
- var body = doc.body;
- var documentElement = doc.documentElement;
- assert.equal(body.parentElement, documentElement);
- assert.isNull(documentElement.parentElement);
- });
-
- test('contains', function() {
- var div = document.createElement('div');
- assert.isTrue(div.contains(div));
-
- div.textContent = 'a';
- var textNode = div.firstChild;
- assert.isTrue(textNode.contains(textNode));
- assert.isTrue(div.contains(textNode));
- assert.isFalse(textNode.contains(div));
-
- var doc = div.ownerDocument;
- assert.isTrue(doc.contains(doc));
- assert.isFalse(doc.contains(div));
- assert.isFalse(doc.contains(textNode));
-
- assert.isFalse(div.contains(null));
- assert.isFalse(div.contains());
- });
-
- test('instanceof', function() {
- var div = document.createElement('div');
- assert.instanceOf(div, HTMLElement);
- assert.instanceOf(div, Element);
- assert.instanceOf(div, EventTarget);
- });
-
- test('cloneNode(false)', function() {
- var doc = wrap(document);
- var a = document.createElement('a');
- a.href = 'http://domain.com/';
- a.textContent = 'text';
- var textNode = a.firstChild;
-
- var aClone = a.cloneNode(false);
-
- assert.equal(aClone.tagName, 'A');
- assert.equal(aClone.href, 'http://domain.com/');
- expectStructure(aClone, {});
- });
-
- test('cloneNode(true)', function() {
- var doc = wrap(document);
- var a = document.createElement('a');
- a.href = 'http://domain.com/';
- a.textContent = 'text';
- var textNode = a.firstChild;
-
- var aClone = a.cloneNode(true);
- var textNodeClone = aClone.firstChild;
-
- assert.equal(aClone.tagName, 'A');
- assert.equal(aClone.href, 'http://domain.com/');
- expectStructure(aClone, {
- firstChild: textNodeClone,
- lastChild: textNodeClone
- });
- expectStructure(textNodeClone, {
- parentNode: aClone
- });
- });
-
- test('cloneNode with shadowRoot', function() {
- var div = document.createElement('div');
- var a = div.appendChild(document.createElement('a'));
- var sr = a.createShadowRoot();
- sr.innerHTML = '';
- div.offsetHeight;
- assert.equal(unwrap(div).innerHTML, '');
-
- var clone = div.cloneNode(true);
- assert.equal(clone.innerHTML, '');
- clone.offsetHeight;
- // shadow roots are not cloned.
- assert.equal(unwrap(clone).innerHTML, '');
- });
-
- test('insertBefore', function() {
- var parent = document.createElement('div');
- var c1 = document.createElement('div');
- var c2 = document.createElement('div');
- var c3 = document.createElement('div');
- parent.insertBefore(c3);
- parent.insertBefore(c2, c3);
- parent.insertBefore(c1, c2);
-
- assert.equal(parent.firstChild, c1);
- assert.equal(c1.nextElementSibling, c2);
- assert.equal(c2.nextElementSibling, c3);
- });
-
- test('textContent of comment', function() {
- var comment = document.createComment('abc');
- assert.equal(comment.textContent, 'abc');
- });
-
- test('textContent ignores comments', function() {
- var div = document.createElement('div');
- div.innerHTML = 'abef';
- assert.equal(div.textContent, 'abef');
- });
-
- test('null textContent', function() {
- var div = document.createElement('div');
- var root = div.createShadowRoot();
- div.textContent = null;
- assert.equal(div.textContent, '');
- });
-
- test('normalize', function() {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode('foo\n'));
- var span = document.createElement('span');
- span.appendChild(document.createTextNode('buzz'));
- span.appendChild(document.createTextNode('quux'));
- div.appendChild(span);
- div.appendChild(document.createTextNode('bar\n'));
- assert.equal(div.textContent, 'foo\nbuzzquuxbar\n');
-
- div.normalize();
-
- assert.equal(div.textContent, 'foo\nbuzzquuxbar\n');
- assert.equal(div.childNodes.length, 3);
- assert.equal(div.firstChild.textContent, 'foo\n');
- assert.equal(div.firstChild.nextSibling, span);
- assert.equal(span.childNodes.length, 1);
- assert.equal(span.firstChild.textContent, 'buzzquux');
- assert.equal(span.nextSibling, div.lastChild);
- assert.equal(div.lastChild.textContent, 'bar\n');
- });
-
- test('normalize with shadowroot', function() {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode('foo\n'));
- var sr = div.createShadowRoot();
- sr.appendChild(document.createTextNode('buzz'));
- sr.appendChild(document.createTextNode('quux'));
- div.appendChild(document.createTextNode('bar\n'));
- assert.equal(div.textContent, 'foo\nbar\n');
- assert.equal(sr.textContent, 'buzzquux');
-
- div.normalize();
-
- assert.equal(div.textContent, 'foo\nbar\n');
- assert.equal(sr.textContent, 'buzzquux');
- assert.equal(div.childNodes.length, 1);
- assert.equal(div.firstChild.textContent, 'foo\nbar\n');
- assert.equal(sr.childNodes.length, 2);
- assert.equal(sr.firstChild.textContent, 'buzz');
- assert.equal(sr.firstChild.nextSibling.textContent, 'quux');
- });
-
- test('normalize - issue 441', function() {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode('a'));
- div.appendChild(document.createTextNode('b'));
- div.appendChild(document.createElement('span'));
- div.appendChild(document.createTextNode('c'));
- div.appendChild(document.createTextNode('d'));
-
- div.normalize();
-
- assert.equal(div.textContent, 'abcd');
- assert.equal(div.childNodes.length, 3);
- });
-
- test('normalize - issue 145', function() {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(''));
- div.appendChild(document.createTextNode(''));
- div.appendChild(document.createTextNode(''));
- var childDiv = document.createElement('div');
- childDiv.appendChild(document.createTextNode(''));
- childDiv.appendChild(document.createTextNode(''));
- div.appendChild(childDiv);
-
- assert.equal(div.childNodes.length, 4);
- assert.equal(childDiv.childNodes.length, 2);
-
- div.normalize();
-
- assert.equal(div.childNodes.length, 1);
- assert.equal(childDiv.childNodes.length, 0);
- });
-
- test('appendChild last and first', function() {
- var a = document.createElement('a');
- a.innerHTML = '';
- var b = a.firstChild;
- var sr = a.createShadowRoot();
-
- var c = document.createElement('c');
- c.innerHTML = '';
- var d = c.firstChild;
- c.appendChild(b);
-
- var cs = c.childNodes;
- assert.equal(cs.length, 2);
- assert.equal(cs[0], d);
- assert.equal(cs[1], b);
-
- c.removeChild(b);
- cs = c.childNodes;
- assert.equal(cs.length, 1);
- assert.equal(cs[0], d);
- });
-
- test('isEqualNode', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var clone = div.cloneNode(true);
- assert.isTrue(div.isEqualNode(clone));
- clone.innerHTML = "
x
";
- assert.isFalse(div.isEqualNode(clone));
- });
-
-});
diff --git a/tests/ShadowDOM/js/NonElementParentNodeInterface.js b/tests/ShadowDOM/js/NonElementParentNodeInterface.js
deleted file mode 100644
index 4fac0d6..0000000
--- a/tests/ShadowDOM/js/NonElementParentNodeInterface.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * @license
- * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('NonElementParentNodeInterface', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- var div;
- setup(function() {
- div = document.createElement('div');
- document.body.appendChild(div);
- });
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- });
-
- test('getElementById', function() {
- div.innerHTML = '';
- var a = div.firstChild;
- var b = div.lastChild;
-
- assert.equal(document.getElementById('a'), a);
- assert.equal(document.getElementById('b'), b);
- });
-
- test('getElementById in shadowRoot', function() {
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
- var b = sr.lastChild;
-
- assert.equal(sr.getElementById('a'), a);
- assert.equal(sr.getElementById('b'), b);
- assert.isNull(document.getElementById('a'));
- assert.isNull(wrap(document).getElementById('b'));
-
- div.offsetHeight;
-
- // Check after rendering:
- assert.equal(sr.getElementById('a'), a);
- assert.equal(sr.getElementById('b'), b);
- assert.isNull(document.getElementById('a'));
- assert.isNull(wrap(document).getElementById('b'));
- });
-
- test('getElementById with a non CSS ID', function() {
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
- var b = sr.lastChild;
-
- assert.equal(sr.getElementById(1), a);
- assert.equal(sr.getElementById(2), b);
- assert.isNull(document.getElementById(1));
- assert.isNull(wrap(document).getElementById(2));
-
- div.offsetHeight;
-
- // Check after rendering:
- assert.equal(sr.getElementById(1), a);
- assert.equal(sr.getElementById(2), b);
- assert.isNull(document.getElementById(1));
- assert.isNull(wrap(document).getElementById(2));
- });
-
- test('getElementById with a non ID', function() {
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
-
- assert.isNull(sr.getElementById('a b'));
- });
-
-
- test('getElementById in DocumentFragment', function() {
- var df = document.createDocumentFragment();
- df.innerHTML = '';
- var a = df.firstChild;
- var b = df.lastChild;
-
- assert.equal(df.getElementById('a'), a);
- assert.equal(df.getElementById('b'), b);
- });
-
- test('getElementById in template content', function() {
- div.innerHTML = '';
- var template = div.firstChild;
- var content = template.content;
-
- var a = content.firstChild;
- var b = content.lastChild;
-
- assert.equal(content.getElementById('a'), a);
- assert.equal(content.getElementById('b'), b);
- assert.isNull(document.getElementById('a'));
- assert.isNull(wrap(document).getElementById('b'));
- });
-
-});
diff --git a/tests/ShadowDOM/js/ParentNodeInterface.js b/tests/ShadowDOM/js/ParentNodeInterface.js
deleted file mode 100644
index 72b3d6c..0000000
--- a/tests/ShadowDOM/js/ParentNodeInterface.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('ParentNodeInterface', function() {
-
- test('childElementCount', function() {
- var div = document.createElement('div');
- div.innerHTML = 'ac';
- assert.equal(div.childElementCount, 1);
- div.appendChild(document.createElement('d'));
- assert.equal(div.childElementCount, 2);
- div.appendChild(document.createTextNode('e'));
- assert.equal(div.childElementCount, 2);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = 'fg';
-
- div.offsetHeight; // trigger rendering
-
- assert.equal(sr.childElementCount, 1);
- assert.equal(div.childElementCount, 2);
- });
-
- test('children', function() {
- var div = document.createElement('div');
- div.innerHTML = 'ac';
- var b = div.firstChild.nextSibling;
-
- assertArrayEqual(div.children, [b]);
- var d = div.appendChild(document.createElement('d'));
- assertArrayEqual(div.children, [b, d]);
- div.appendChild(document.createTextNode('e'));
- assertArrayEqual(div.children, [b, d]);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = 'fg';
- var content = sr.firstChild.nextSibling;
-
- div.offsetHeight; // trigger rendering
-
- assertArrayEqual(sr.children, [content]);
- assertArrayEqual(div.children, [b, d]);
- });
-
- test('firstElementChild', function() {
- var div = document.createElement('div');
- div.innerHTML = 'ac';
- var b = div.firstChild.nextSibling;
-
- assert.equal(div.firstElementChild, b);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = 'fg';
- var content = sr.firstChild.nextSibling;
-
- div.offsetHeight; // trigger rendering
-
- assert.equal(sr.firstElementChild, content);
- assert.equal(div.firstElementChild, b);
- });
-
- test('lastElementChild', function() {
- var div = document.createElement('div');
- div.innerHTML = 'ac';
- var b = div.firstChild.nextSibling;
-
- assert.equal(div.lastElementChild, b);
-
- var sr = div.createShadowRoot();
- sr.innerHTML = 'fg';
- var content = sr.firstChild.nextSibling;
-
- div.offsetHeight; // trigger rendering
-
- assert.equal(sr.lastElementChild, content);
- assert.equal(div.lastElementChild, b);
- });
-
-});
diff --git a/tests/ShadowDOM/js/Range.js b/tests/ShadowDOM/js/Range.js
deleted file mode 100644
index e31f922..0000000
--- a/tests/ShadowDOM/js/Range.js
+++ /dev/null
@@ -1,538 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Range', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
- var wrapIfNeeded = ShadowDOMPolyfill.wrapIfNeeded;
- var isNativeShadowDomSupported;
-
- var hosts;
- var customElementPrefix = "range-custom-element-";
- var nativeCustomElementPrefix = "range-native-element-";
- var customElementIndex = 0;
- var nativeCustomElementIndex = 0;
-
- setup(function() {
- isNativeShadowDomSupported =
- !!unwrap(document.createElement('div')).createShadowRoot;
- });
-
- function removeHosts() {
- if (hosts) {
- hosts.forEach(function(host) {
- if (host && host.parentNode) {
- host.parentNode.removeChild(wrapIfNeeded(host));
- }
- });
- hosts = undefined;
- }
- }
-
- function getNewCustomElementType() {
- return customElementPrefix + customElementIndex++;
- }
-
- function getNewNativeCustomElementType() {
- return nativeCustomElementPrefix + nativeCustomElementIndex++;
- }
-
- function createCustomElement(name, shadowDomContentsArray, native) {
-
- var prototype = Object.create(HTMLElement.prototype);
- prototype.createdCallback = function() {
- var element = this;
- if (native) {
- element = unwrap(this);
- }
- createShadowDom(element, shadowDomContentsArray);
- };
-
- return document.registerElement(name, {prototype: prototype});
- }
-
- // If the host has native shadow dom then we need to return native
- // range. Native range is just a polyfill Range unwrapped.
- function createRangeForHost(host) {
- var range = document.createRange();
-
- // If we are dealing with native shadow dom, expose the range object
- // as a native range object by just unwrapping it.
- //noinspection JSUnresolvedVariable
- if (hasNativeShadowRoot(host)) {
- range = unwrap(range);
- }
-
- return range;
- }
-
- function hasNativeShadowRoot(node) {
- return node && node.shadowRoot && !(node.shadowRoot instanceof ShadowRoot);
- }
-
- function createCustomElementWithPolyfillShadowDom(shadowDomContentsArray) {
- var customElementType = getNewCustomElementType();
- createCustomElement(customElementType, shadowDomContentsArray);
- return document.createElement(customElementType);
- }
-
- function createStandardElementWithPolyfillShadowDom(shadowDomContentsArray,
- elementType) {
- var element = document.createElement(elementType);
- return createShadowDom(element, shadowDomContentsArray);
- }
-
- function createHostWithPolyfillShadowDom(shadowDomContentsArray,
- elementType) {
- if (!elementType) {
- return createCustomElementWithPolyfillShadowDom(shadowDomContentsArray);
- } else {
- return createStandardElementWithPolyfillShadowDom(shadowDomContentsArray,
- elementType);
- }
- }
-
- function createShadowDom(element, shadowDomContentsArray) {
- shadowDomContentsArray.forEach(function(shadowDomContent) {
- element.createShadowRoot().innerHTML = shadowDomContent;
- });
- return element;
- }
-
- function createStandardElementWithNativeShadowDom(shadowDomContentsArray,
- elementType) {
- var element = document.createElement(elementType);
- return createShadowDom(unwrap(element), shadowDomContentsArray);
- }
-
- function createCustomElementWithNativeShadowDom(shadowDomContentsArray) {
- var element;
- var nativeElementType = getNewNativeCustomElementType();
- createCustomElement(nativeElementType, shadowDomContentsArray, true);
- element = document.createElement(nativeElementType);
- element = unwrap(element);
- assert.isNotNull(element.shadowRoot);
- }
-
- function createHostWithNativeShadowDom(shadowDomContentsArray, elementType) {
-
- if (!isNativeShadowDomSupported) {
- return;
- }
-
- if (!elementType) {
- return createCustomElementWithNativeShadowDom(shadowDomContentsArray,
- elementType);
- } else {
- return createStandardElementWithNativeShadowDom(shadowDomContentsArray,
- elementType);
- }
- }
-
- // Create hosts with polyfill shadow dom and native shadow dom
- // if available. The two hosts then will be tested by setting
- // the innerHTML of those hosts and using the polyfill range or
- // the native range. The results should be the same in both cases.
- function createHostsWithShadowDom(shadowDomContentsArray, elementType) {
-
- var hostWithPolyFillShadowDom =
- createHostWithPolyfillShadowDom(shadowDomContentsArray, elementType);
- var hostWithNativeShadowDom =
- createHostWithNativeShadowDom(shadowDomContentsArray, elementType);
-
- var hosts = [];
- assert.isObject(hostWithPolyFillShadowDom);
-
- hosts.push(hostWithPolyFillShadowDom);
- if (hostWithNativeShadowDom) {
- hosts.push(hostWithNativeShadowDom);
- }
-
- return hosts;
- }
-
- // This function sets the innerHTML for some host element. The host could
- // have native shadow dom or polyfill shadow dom. Then we start selecting
- // the range based on the set innerHTML and the range has to work
- // regardless of the structure of the shadow dom.
- function testRangeWith3SpansHTML(host) {
-
- host.innerHTML = "OneTwoThree";
-
- assert.isNotNull(host.shadowRoot);
-
- // Force rendering for the host with the polyfill shadow dom.
- // Of course the host with native shadow dom does not need it.
- host.offsetWidth;
-
- var range = createRangeForHost(host);
-
- // We are using the polyfill selection for native and polyfill ranges.
- // It has no impact on the tests results.
- var selection = document.getSelection();
- if (selection.rangeCount > 0) {
- selection.removeAllRanges();
- }
-
- // We do not really have to add the range to the selection.
- // It provides visual feedback of the range while we are debugging.
-
- range.setStart(host, 0);
- range.setEnd(host, 2);
- selection.addRange(range);
-
- assert.isTrue(range.startContainer === host);
- assert.isTrue(range.endContainer === host);
- assert.isTrue(range.commonAncestorContainer === host);
- assert.isTrue(range.toString() === "OneTwo");
-
- range.setStart(host, 0);
- range.setEnd(host, 1);
- assert.isTrue(range.toString() === "One");
- selection.removeAllRanges();
- selection.addRange(range);
-
- range.setStart(host, 1);
- range.setEnd(host, 2);
- assert.isTrue(range.toString() === "Two");
- selection.removeAllRanges();
- selection.addRange(range);
-
- range.setStart(host, 2);
- range.setEnd(host, 3);
- assert.isTrue(range.toString() === "Three");
- selection.removeAllRanges();
- selection.addRange(range);
-
- range.setStart(host, 0);
- range.setEnd(host, 3);
- assert.isTrue(range.toString() === "OneTwoThree");
- selection.removeAllRanges();
- selection.addRange(range);
-
- // Make sure we can select without specifying the host
-
- // Test selecting the spans inside the spans
- var span0 = host.childNodes[0];
- var span2 = host.childNodes[2];
- range.setStart(span0, 1);
- range.setEnd(span2, 0);
- assert.isTrue(range.toString() === "Two");
- selection.removeAllRanges();
- selection.addRange(range);
-
- // create span0TextNode and span2TextNode for test readability.
- // Test selecting the text nodes inside the spans
- var span0TextNode = span0.childNodes[0];
- var span2TextNode = span2.childNodes[0];
- range.setStart(span0TextNode, 1);
- range.setEnd(span2TextNode, 1);
- selection.removeAllRanges();
- selection.addRange(range);
- assert.isTrue(range.toString() === "neTwoT");
- }
-
- function testRangeWithHosts(hosts) {
- hosts.forEach(function(host) {
- document.body.appendChild(wrapIfNeeded(host));
- testRangeWith3SpansHTML(host);
- });
- }
-
- suite('Standard elements (no Shadow Dom)', function() {
- var div;
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- });
-
- test('instanceof', function() {
- var range = document.createRange();
- assert.instanceOf(range, Range);
-
- var range2 = wrap(document).createRange();
- assert.instanceOf(range2, Range);
- });
-
- test('constructor', function() {
- var range = document.createRange();
- assert.equal(Range, range.constructor);
- });
-
- test('createContextualFragment', function() {
- // IE9 does not support createContextualFragment.
- if (!Range.prototype.createContextualFragment)
- return;
-
- var range = document.createRange();
- var container = document.body || document.head;
-
- range.selectNode(container);
-
- var fragment = range.createContextualFragment('');
-
- assert.instanceOf(fragment, DocumentFragment);
- assert.equal(fragment.firstChild.localName, 'b');
- assert.equal(fragment.childNodes.length, 1);
- });
-
- test('WebIDL attributes', function() {
- var range = document.createRange();
-
- assert.isTrue('collapsed' in range);
- assert.isFalse(range.hasOwnProperty('collapsed'));
-
- assert.isTrue('commonAncestorContainer' in range);
- assert.isFalse(range.hasOwnProperty('commonAncestorContainer'));
-
- assert.isTrue('endContainer' in range);
- assert.isFalse(range.hasOwnProperty('endContainer'));
-
- assert.isTrue('endOffset' in range);
- assert.isFalse(range.hasOwnProperty('endOffset'));
-
- assert.isTrue('startContainer' in range);
- assert.isFalse(range.hasOwnProperty('startContainer'));
-
- assert.isTrue('startOffset' in range);
- assert.isFalse(range.hasOwnProperty('startOffset'));
- });
-
- test('toString', function() {
- var range = document.createRange();
- div = document.createElement('div');
- document.body.appendChild(div);
- div.innerHTML = 'abc';
- var a = div.firstChild;
- var b = a.nextSibling;
- range.selectNode(b);
- assert.equal(range.toString(), 'b');
- });
-
- });
-
- suite('Standard+Custom elements with Shadow Dom', function() {
-
- teardown(function() {
- removeHosts();
- });
-
- // create a prototype for each test, so we don't get into some
- // other issues that has nothing to do with the Range.
- test('custom - ', function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "";
- hosts = createHostsWithShadowDom([shadowDomContent]);
- testRangeWithHosts(hosts);
- });
-
- test('custom - ', function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "";
- hosts = createHostsWithShadowDom([shadowDomContent]);
- testRangeWithHosts(hosts);
- });
-
- test("custom - wrapped in a div container", function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "
";
- hosts = createHostsWithShadowDom([shadowDomContent]);
- testRangeWithHosts(hosts);
- });
-
- test("custom - wrapped in a div container", function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "
";
- hosts = createHostsWithShadowDom([shadowDomContent]);
- testRangeWithHosts(hosts);
- });
-
- test("custom - wrapped and more", function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "
before
";
- shadowDomContent += "
";
- shadowDomContent += "
after
";
- hosts = createHostsWithShadowDom([shadowDomContent]);
- testRangeWithHosts(hosts);
- });
-
- test("custom - wrapped and more", function() {
- if (!document.registerElement)
- return;
- var shadowDomContent = "
";
- hosts = createHostsWithShadowDom([shadowDomContent], "div");
- testRangeWithHosts(hosts);
- });
-
- });
-
- suite("Standard+Custom elements with oldest+youngest Shadow Dom", function() {
-
- teardown(function() {
- removeHosts();
- });
-
- test("div with and ", function() {
- var shadowDomContentsArray = [
- "",
- ""
- ];
-
- hosts = createHostsWithShadowDom(shadowDomContentsArray, "div");
- testRangeWithHosts(hosts);
- });
-
- test("custom with and ", function() {
- if (!document.registerElement)
- return;
-
- var shadowDomContentsArray = [
- "",
- ""
- ];
-
- hosts = createHostsWithShadowDom(shadowDomContentsArray);
- testRangeWithHosts(hosts);
- });
-
- test("div with wrapped and ", function() {
- var shadowDomContentsArray = [
- "
",
- "
"
- ];
-
- hosts = createHostsWithShadowDom(shadowDomContentsArray, "div");
- testRangeWithHosts(hosts);
- });
-
- test("custom with wrapped and and more", function() {
- if (!document.registerElement)
- return;
-
- var oldestShadowDom = "
In Oldest shadow dom before
" +
- "
" +
- "
In Oldest shadow dom after
";
-
- var youngestShadowDom = "
In youngest shadow dom before
" +
- "
" +
- "
In youngest shadow dom after
";
-
- var shadowDomContentsArray = [oldestShadowDom, youngestShadowDom];
-
- hosts = createHostsWithShadowDom(shadowDomContentsArray);
- testRangeWithHosts(hosts);
- })
-
- });
-
- suite("multiple with select (not supported)", function() {
-
- teardown(function() {
- removeHosts();
- });
-
- // Maybe someone can make sense of what range in
- // different trees means.
- function testRangeWithWithFragmentedContent(host) {
-
- host.innerHTML = "bold1italic1" +
- "bold2italic2" +
- "
some text
";
-
- assert.isNotNull(host.shadowRoot);
-
- // Force rendering for the host with the polyfill
- // shadow dom. Of course the host with native shadow
- // dom does not need it.
- host.offsetWidth;
-
- var range = createRangeForHost(host);
-
- // We are using the polyfill selection for native
- // and polyfill ranges. It has no impact on the tests results.
- var selection = document.getSelection();
- if (selection.rangeCount > 0) {
- selection.removeAllRanges();
- }
-
- // Just make sure we do not throw an exception
- range.setStart(host, 0);
- range.setEnd(host, 2);
-
- range.setStart(host, 0);
- range.setEnd(host, 1);
-
- range.setStart(host, 0);
- range.setEnd(host, host.childNodes.length + 1);
-
- assert.isTrue(range.startContainer === host);
- assert.isTrue(range.endContainer === host);
- assert.isTrue(range.commonAncestorContainer === host);
- //assert.isTrue(range.toString() === "bold1italic1");
- }
-
- test.skip("div with multiple wrapped", function() {
- var shadowDomContent = "Bold tags:
" +
- "
" +
- "Italic tags:
" +
- "
" +
- "Others:
";
-
- hosts = createHostsWithShadowDom([shadowDomContent], "div");
- hosts.forEach(function(host) {
- document.body.appendChild(wrapIfNeeded(host));
- testRangeWithWithFragmentedContent(host);
- });
- });
-
- test.skip("div with multiple ", function() {
- var shadowDomContent = "Bold tags:" +
- " Italic tags:" +
- " Others:";
-
- hosts = createHostsWithShadowDom([shadowDomContent], "div");
- hosts.forEach(function(host) {
- // I am not sure even the native chrome implementation makes
- // sense. The meaning of selecting range in different trees needs to
- // be defined. Not sure if it even makes sense. It did not to me.
- document.body.appendChild(wrapIfNeeded(host));
- testRangeWithWithFragmentedContent(host);
- });
- });
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/SVGElement.js b/tests/ShadowDOM/js/SVGElement.js
deleted file mode 100644
index 0da56a4..0000000
--- a/tests/ShadowDOM/js/SVGElement.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('SVGElement', function() {
-
- var SVG_NS = 'http://www.w3.org/2000/svg';
-
- test('Basics', function() {
- var el = document.createElementNS(SVG_NS, 'svg');
-
- assert.equal(el.localName, 'svg');
- assert.equal(el.tagName, 'svg');
- assert.equal(el.namespaceURI, SVG_NS);
- assert.instanceOf(el, SVGElement);
- assert.instanceOf(el, Element);
- assert.instanceOf(el, Node);
- assert.instanceOf(el, EventTarget);
- assert.notInstanceOf(el, HTMLElement);
- });
-
- test('Basics innerHTML', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var el = div.firstChild;
-
- assert.equal(el.localName, 'svg');
- assert.equal(el.tagName, 'svg');
- assert.equal(el.namespaceURI, SVG_NS);
- assert.instanceOf(el, SVGElement);
- assert.instanceOf(el, Element);
- assert.instanceOf(el, Node);
- assert.instanceOf(el, EventTarget);
- assert.notInstanceOf(el, HTMLElement);
- });
-
- test('template', function() {
- var el = document.createElementNS(SVG_NS, 'template');
-
- assert.equal(el.localName, 'template');
- assert.equal(el.tagName, 'template');
- assert.equal(el.namespaceURI, SVG_NS);
-
- // IE does not create an SVGElement if the local name is not a known SVG
- // element.
- // Safari 7 has the same issue but nightly WebKit works as expected.
- // assert.instanceOf(el, SVGElement);
-
- assert.instanceOf(el, Element);
- assert.instanceOf(el, Node);
- assert.instanceOf(el, EventTarget);
- assert.notInstanceOf(el, HTMLElement);
- });
-
- test('classList', function() {
- var el = document.createElementNS(SVG_NS, 'svg');
- el.setAttribute('class', 'a b');
-
- assert.isTrue(el.classList === undefined ||
- (el.classList instanceof DOMTokenList));
-
- if (el.classList !== undefined) {
- assert.equal(el.classList.length, 2);
- assert.isTrue(el.classList.contains('a'));
- assert.isTrue(el.classList.contains('b'));
- }
- });
-
- test('ownerSVGElement', function() {
- var el = document.createElementNS(SVG_NS, 'svg');
- var el2 = document.createElementNS(SVG_NS,'svg');
- var g = document.createElementNS(SVG_NS, 'g');
- el.appendChild(g);
-
- assert.equal(g.ownerSVGElement, el);
-
- el2.appendChild(g);
-
- assert.equal(g.ownerSVGElement, el2);
- });
-});
diff --git a/tests/ShadowDOM/js/SVGElementInstance.js b/tests/ShadowDOM/js/SVGElementInstance.js
deleted file mode 100644
index 9f3aa44..0000000
--- a/tests/ShadowDOM/js/SVGElementInstance.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('SVGElementInstance', function() {
-
- var div;
-
- teardown(function() {
- if (div) {
- if (div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- }
- });
-
- var svgCode = '\
- ';
-
- function getInstanceRoot() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = svgCode;
- var svg = div.firstElementChild;
- var useElement = svg.firstElementChild.nextElementSibling;
- return useElement.instanceRoot;
- }
-
- test('instanceof SVGUseElement', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = svgCode;
- var svg = div.firstElementChild;
- var useElement = svg.firstElementChild.nextElementSibling;
- assert.instanceOf(useElement, SVGUseElement);
- assert.instanceOf(useElement, SVGElement);
- assert.instanceOf(useElement, Element);
- assert.instanceOf(useElement, EventTarget);
- });
-
- test('instanceof SVGElementInstance', function() {
- // Firefox does not implement SVGElementInstance.
- if (/Firefox/.test(navigator.userAgent))
- return;
-
- var instanceRoot = getInstanceRoot();
-
- // Safari 6 seems to return null here in some cases.
- if (!instanceRoot)
- return;
-
- assert.instanceOf(instanceRoot, SVGElementInstance);
- assert.instanceOf(instanceRoot, EventTarget);
- });
-
- test('correspondingUseElement', function() {
- // Firefox does not implement SVGElementInstance.
- if (/Firefox/.test(navigator.userAgent))
- return;
-
- div = document.body.appendChild(document.createElement('div'));
- div.innerHTML = svgCode;
- var svg = div.firstElementChild;
- var useElement = svg.firstElementChild.nextElementSibling;
- var instanceRoot = useElement.instanceRoot;
-
- // Safari 6 seems to return null here in some cases.
- if (!instanceRoot)
- return;
-
- assert.equal(useElement, instanceRoot.correspondingUseElement);
- });
-
- test('correspondingElement', function() {
- // Firefox does not implement SVGElementInstance.
- if (/Firefox/.test(navigator.userAgent))
- return;
-
- var instanceRoot = getInstanceRoot();
-
- // Safari 6 seems to return null here in some cases.
- if (!instanceRoot)
- return;
-
- assert.equal('g', instanceRoot.correspondingElement.localName);
- });
-
- test('tree', function() {
- // Firefox does not implement SVGElementInstance.
- if (/Firefox/.test(navigator.userAgent))
- return;
-
- var instanceRoot = getInstanceRoot();
-
- // Safari 6 seems to return null here in some cases.
- if (!instanceRoot)
- return;
-
- assert.equal('line', instanceRoot.firstChild.correspondingElement.localName);
- assert.equal('line', instanceRoot.lastChild.correspondingElement.localName);
-
- // IE always returns new wrappers for all the accessors.
- if (/Trident|Edge/.test(navigator.userAgent))
- return;
-
- assert.equal(instanceRoot.firstChild, instanceRoot.lastChild);
- assert.equal(instanceRoot, instanceRoot.firstChild.parentNode);
- assert.isNull(instanceRoot.parentNode);
- });
-
-});
diff --git a/tests/ShadowDOM/js/Selection.js b/tests/ShadowDOM/js/Selection.js
deleted file mode 100644
index d3c25bd..0000000
--- a/tests/ShadowDOM/js/Selection.js
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Selection', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
- var div, a, b, c;
-
- teardown(function() {
- if (div && div.parentNode)
- div.parentNode.removeChild(div);
- div = a = b = c = undefined;
- });
-
- setup(function() {
- div = document.createElement('div');
- div.innerHTML = 'abc';
- a = div.firstChild;
- b = a.nextSibling;
- c = div.lastChild;
- document.body.appendChild(div);
- });
-
-
- test('document.getSelection()', function() {
- var selection = document.getSelection();
- assert.instanceOf(selection, Selection);
-
- var doc = wrap(document);
- selection = doc.getSelection();
- assert.instanceOf(selection, Selection);
- });
-
- test('window.getSelection()', function() {
- var selection = window.getSelection();
- assert.instanceOf(selection, Selection);
-
- var win = wrap(window);
- selection = win.getSelection();
- assert.instanceOf(selection, Selection);
- });
-
- test('constructor', function() {
- var selection = window.getSelection();
- assert.equal(Selection, selection.constructor);
- });
-
- test('getSelection()', function() {
- var selection = getSelection();
- assert.instanceOf(selection, Selection);
- });
-
- test('basics', function() {
- var selection = window.getSelection();
- selection.selectAllChildren(div);
-
- assert.equal(selection.toString(), 'abc');
-
- assert.isFalse(selection.isCollapsed);
- assert.equal(selection.rangeCount, 1);
-
- // https://code.google.com/p/chromium/issues/detail?id=336821
- if (/WebKit/.test(navigator.userAgent))
- return;
-
- assert.equal(selection.anchorNode, div);
- assert.equal(selection.anchorOffset, 0);
-
- assert.equal(selection.focusNode, div);
- assert.equal(selection.focusOffset, 3);
- });
-
- test('getRangeAt', function() {
- var selection = window.getSelection();
- selection.selectAllChildren(div);
- var range = selection.getRangeAt(0);
- assert.instanceOf(range, Range);
- });
-
- test('collapse', function() {
- var selection = window.getSelection();
-
- for (var i = 0; i < 4; i++) {
- selection.selectAllChildren(div);
- selection.collapse(div, i);
-
- assert.isTrue(selection.isCollapsed);
- assert.equal(selection.toString(), '');
-
- // https://code.google.com/p/chromium/issues/detail?id=336821
- if (/WebKit/.test(navigator.userAgent))
- continue;
-
- assert.equal(selection.anchorNode, div);
- assert.equal(selection.anchorOffset, i);
-
- assert.equal(selection.focusNode, div);
- assert.equal(selection.focusOffset, i);
- }
- });
-
- test('Make sure Selection.extend is not supported if browser does not support it.', function() {
- var originalSelection = unwrap(window.getSelection());
- var wrapperSelection = window.getSelection();
- assert(!!originalSelection.extend === !!wrapperSelection.extend);
- });
-
- test('extend', function() {
-
- var selection = window.getSelection();
- if (!selection.extend){
- // Nothing to test if the selection does not support extend.
- // do not fail. Code that uses browser with no extend in the selection knows how to handle it.
- // Just do not fake the availability of extend.
- return;
- }
-
- for (var i = 0; i < 4; i++) {
- selection.selectAllChildren(div);
- selection.extend(div, i);
-
- assert.equal(selection.isCollapsed, i === 0);
- assert.equal(selection.toString(), 'abc'.slice(0, i));
-
- // https://code.google.com/p/chromium/issues/detail?id=336821
- if (/WebKit/.test(navigator.userAgent))
- continue;
-
- assert.equal(selection.anchorNode, div);
- assert.equal(selection.anchorOffset, 0);
-
- assert.equal(selection.focusNode, div);
- assert.equal(selection.focusOffset, i);
- }
- });
-
- test('addRange', function() {
- var selection = window.getSelection();
- selection.removeAllRanges();
- var range = document.createRange();
- range.selectNode(b);
- selection.addRange(range);
-
- // Uncertain why this fails in Blink. The same test passes without the
- // shadow dom polyfill in Blink.
- if (/WebKit/.test(navigator.userAgent))
- return;
-
- assert.equal(selection.toString(), 'b');
- });
-
- test('removeRange', function() {
- // Not implemented in Blink.
- if (/WebKit/.test(navigator.userAgent))
- return;
-
- var selection = window.getSelection();
- selection.selectAllChildren(div);
- var range = selection.getRangeAt(0);
- selection.removeRange(range);
- assert.equal(selection.toString(), '');
- });
-
- test('containsNode', function() {
- // IE legacy document modes do not have containsNode.
- if (/Trident/.test(navigator.userAgent))
- return;
-
- var selection = window.getSelection();
- selection.selectAllChildren(div);
-
- assert.isFalse(selection.containsNode(div));
- assert.isFalse(selection.containsNode(document));
- assert.isFalse(selection.containsNode(document.body));
-
- assert.isTrue(selection.containsNode(a, true));
- assert.isTrue(selection.containsNode(b, true));
- assert.isTrue(selection.containsNode(c, true));
- });
-
-});
diff --git a/tests/ShadowDOM/js/ShadowRoot.js b/tests/ShadowDOM/js/ShadowRoot.js
deleted file mode 100644
index 152fe45..0000000
--- a/tests/ShadowDOM/js/ShadowRoot.js
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('ShadowRoot', function() {
-
- var div;
- teardown(function() {
- if (div) {
- if (div.parentNode)
- div.parentNode.removeChild(div);
- div = undefined;
- }
- });
-
- test('elementFromPoint', function() {
- div = document.body.appendChild(document.createElement('div'));
- div.style.cssText = 'position: fixed; background: red; ' +
- 'width: 10px; height: 10px; top: 0; left: 0;';
- var sr = div.createShadowRoot();
- sr.innerHTML = '';
- var a = sr.firstChild;
- a.style.cssText = 'position: absolute; width: 100%; height: 100%; ' +
- 'background: green';
-
- assert.equal(sr.elementFromPoint(5, 5), a);
-
- var sr2 = a.createShadowRoot();
- assert.equal(sr.elementFromPoint(5, 5), a);
- assert.equal(sr2.elementFromPoint(5, 5), null);
- });
-
- test('getSelection', function() {
- div = document.body.appendChild(document.createElement('div'));
- var sr = div.createShadowRoot();
- sr.innerHTML = 'abc';
-
- var selection = sr.getSelection();
- selection.selectAllChildren(sr);
-
- assert.equal(selection.toString(), 'abc');
-
- assert.isFalse(selection.isCollapsed);
- assert.equal(selection.rangeCount, 1);
-
- // https://code.google.com/p/chromium/issues/detail?id=336821
- if (/WebKit/.test(navigator.userAgent))
- return;
-
- assert.equal(selection.anchorNode, div);
- assert.equal(selection.anchorOffset, 0);
-
- assert.equal(selection.focusNode, div);
- assert.equal(selection.focusOffset, 3);
- });
-
- test('olderShadowRoot', function() {
- var host = document.createElement('div');
- host.innerHTML = 'ab';
- var a = host.firstChild;
- var b = host.lastChild;
-
- var sr = host.createShadowRoot();
- sr.innerHTML = 'a';
-
- host.offsetWidth;
- assert.isNull(sr.olderShadowRoot);
-
- var sr2 = host.createShadowRoot();
- sr2.innerHTML = 'b';
-
- host.offsetWidth;
- assert.equal(sr2.olderShadowRoot, sr);
- });
-
- test('host', function() {
- var host = document.createElement('div');
- var sr = host.createShadowRoot();
- assert.equal(host, sr.host);
-
- var sr2 = host.createShadowRoot();
- assert.equal(host, sr2.host);
- });
-
- test('instanceof', function() {
- var sr = document.createElement('div').createShadowRoot();
- assert.instanceOf(sr, ShadowRoot);
- });
-
- test('constructor', function() {
- var sr = document.createElement('div').createShadowRoot();
- assert.equal(ShadowRoot, sr.constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/Text.js b/tests/ShadowDOM/js/Text.js
deleted file mode 100644
index b8a0b44..0000000
--- a/tests/ShadowDOM/js/Text.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Text', function() {
-
- test('instanceof', function() {
- var div = document.createElement('div');
- div.textContent = 'abc';
- assert.instanceOf(div.firstChild, Text);
- });
-
- test('constructor', function() {
- var div = document.createElement('div');
- div.textContent = 'abc';
- assert.equal(Text, div.firstChild.constructor);
- });
-
- test('splitText', function() {
- var t = document.createTextNode('abcd');
- var t2 = t.splitText(3);
- assert.equal(t.data, 'abc');
- assert.equal(t2.data, 'd');
-
- t = document.createTextNode('abcd');
- t2 = t.splitText(0);
- assert.equal(t.data, '');
- assert.equal(t2.data, 'abcd');
-
- t = document.createTextNode('abcd');
- t2 = t.splitText(4);
- assert.equal(t.data, 'abcd');
- assert.equal(t2.data, '');
- });
-
- test('splitText with too large offset', function() {
- var t = document.createTextNode('abcd');
- assert.throws(function() {
- t.splitText(5);
- });
- });
-
- test('splitText negative offset', function() {
- var t = document.createTextNode('abcd');
- assert.throws(function() {
- t.splitText(-1);
- });
- });
-
- test('splitText siblings', function() {
- var div = document.createElement('div');
- div.innerHTML = 'abcd';
- var t = div.firstChild;
- var b = div.lastChild;
-
- var t2 = t.splitText(3);
- assert.equal(t.data, 'abc');
- assert.equal(t2.data, 'd');
-
- assert.equal(t.nextSibling, t2);
- assert.equal(t2.nextSibling, b);
- });
-
-});
diff --git a/tests/ShadowDOM/js/TouchEvent.js b/tests/ShadowDOM/js/TouchEvent.js
deleted file mode 100644
index 3a53e4b..0000000
--- a/tests/ShadowDOM/js/TouchEvent.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Events', function() {
-
- var unwrap = ShadowDOMPolyfill.unwrap;
- var wrap = ShadowDOMPolyfill.wrap;
-
- try {
- document.createEvent('TouchEvent');
- } catch (ex) {
- // Touch events are not supported
- return;
- }
-
- function createMockTouch(nativeTarget) {
- return {
- clientX: 1,
- clientY: 2,
- screenX: 3,
- screenY: 4,
- pageX: 5,
- pageY: 6,
- identifier: 7,
- webkitRadiusX: 8,
- webkitRadiusY: 9,
- webkitRotationAngle: 10,
- webkitForce: 11,
- target: nativeTarget
- };
- }
-
- test('TouchEvent', function() {
- var e = document.createEvent('TouchEvent');
- assert.instanceOf(e, TouchEvent);
- assert.instanceOf(e, UIEvent);
- assert.instanceOf(e, Event);
- });
-
- test('constructor', function() {
- var e = document.createEvent('TouchEvent');
- assert.equal(TouchEvent, e.constructor);
- });
-
- test('Touch', function() {
- // There is no way to create a native Touch object so we use a mock impl.
-
- var target = document.createElement('div');
- var impl = createMockTouch(unwrap(target));
- var touch = new Touch(impl);
-
- assert.equal(touch.clientX, 1);
- assert.equal(touch.clientY, 2);
- assert.equal(touch.screenX, 3);
- assert.equal(touch.screenY, 4);
- assert.equal(touch.pageX, 5);
- assert.equal(touch.pageY, 6);
- assert.equal(touch.identifier, 7);
- assert.equal(touch.webkitRadiusX, 8);
- assert.equal(touch.webkitRadiusY, 9);
- assert.equal(touch.webkitRotationAngle, 10);
- assert.equal(touch.webkitForce, 11);
- assert.equal(touch.target, target);
- });
-
- test('TouchList', function() {
-
- function createMockTouchList(elements) {
- var arr = [];
- for (var i = 0; i < elements.length; i++) {
- arr[i] = createMockTouch(unwrap(elements[i]));
- }
- return arr;
- }
-
- var a = document.createElement('a');
- var b = document.createElement('b');
- var c = document.createElement('c');
- var d = document.createElement('d');
- var e = document.createElement('e');
- var f = document.createElement('f');
-
- var mockEvent = {
- __proto__: unwrap(document.createEvent('TouchEvent')).__proto__,
- touches: createMockTouchList([a]),
- targetTouches: createMockTouchList([b, c]),
- changedTouches: createMockTouchList([d, e, f])
- };
-
- var event = wrap(mockEvent);
-
- assert.instanceOf(event.touches, TouchList);
- assert.instanceOf(event.targetTouches, TouchList);
- assert.instanceOf(event.changedTouches, TouchList);
-
- assert.equal(event.touches.length, 1);
- assert.equal(event.targetTouches.length, 2);
- assert.equal(event.changedTouches.length, 3);
-
- assert.instanceOf(event.touches[0], Touch);
- assert.instanceOf(event.targetTouches[0], Touch);
- assert.instanceOf(event.targetTouches[1], Touch);
- assert.instanceOf(event.changedTouches[0], Touch);
- assert.instanceOf(event.changedTouches[1], Touch);
- assert.instanceOf(event.changedTouches[2], Touch);
-
- assert.equal(event.touches[0].target, a);
- assert.equal(event.targetTouches[0].target, b);
- assert.equal(event.targetTouches[1].target, c);
- assert.equal(event.changedTouches[0].target, d);
- assert.equal(event.changedTouches[1].target, e);
- assert.equal(event.changedTouches[2].target, f);
- });
-
-});
diff --git a/tests/ShadowDOM/js/TreeScope.js b/tests/ShadowDOM/js/TreeScope.js
deleted file mode 100644
index b903f19..0000000
--- a/tests/ShadowDOM/js/TreeScope.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('TreeScope', function() {
-
- var getTreeScope = ShadowDOMPolyfill.getTreeScope;
-
- test('Basic', function() {
- var div = document.createElement('div');
-
- var ts = getTreeScope(div);
- assert.equal(ts.root, div);
-
- div.innerHTML = '';
- var a = div.firstChild;
- var b = a.firstChild;
-
- assert.equal(getTreeScope(a), ts);
- assert.equal(getTreeScope(b), ts);
- });
-
- test('ShadowRoot', function() {
- var div = document.createElement('div');
-
- var ts = getTreeScope(div);
- assert.equal(ts.root, div);
-
- div.innerHTML = '';
- var a = div.firstChild;
- var b = a.firstChild;
-
- var sr = a.createShadowRoot();
-
- var srTs = getTreeScope(sr);
- assert.equal(srTs.root, sr);
- assert.equal(srTs.parent, ts);
-
- sr.innerHTML = '';
- var c = sr.firstChild;
- var d = c.firstChild;
-
- assert.equal(getTreeScope(c), srTs);
- assert.equal(getTreeScope(d), srTs);
- });
-
- test('change parent in shadow', function() {
- var div = document.createElement('div');
- div.innerHTML = '';
- var a = div.firstChild;
-
- var sr = a.createShadowRoot();
- sr.innerHTML = '';
- var b = sr.firstChild;
-
- var sr2 = b.createShadowRoot();
- sr2.innerHTML = '';
- var c = sr2.firstChild;
-
- var sr3 = a.createShadowRoot();
- sr3.innerHTML = '';
- var d = sr3.firstChild;
-
- var ts1 = getTreeScope(a);
- var ts2 = getTreeScope(b);
- var ts3 = getTreeScope(c);
- var ts4 = getTreeScope(d);
-
- assert.equal(ts1.parent, null);
- assert.equal(ts2.parent, ts1);
- assert.equal(ts3.parent, ts2);
- assert.equal(ts4.parent, ts2);
-
- var div2 = document.createElement('div');
- div2.appendChild(a);
-
- var ts5 = getTreeScope(a);
- assert.notEqual(ts1, ts5);
- assert.equal(ts2.parent, ts5);
- assert.equal(ts3.parent, ts2);
- assert.equal(ts4.parent, ts5);
- });
-
-});
diff --git a/tests/ShadowDOM/js/TreeWalker.js b/tests/ShadowDOM/js/TreeWalker.js
deleted file mode 100644
index a924ee5..0000000
--- a/tests/ShadowDOM/js/TreeWalker.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('TreeWalker', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
- var isWrapper = ShadowDOMPolyfill.isWrapper;
- var containerDiv, childDiv, a, b, c;
-
- teardown(function() {
- if (containerDiv && containerDiv.parentNode)
- containerDiv.parentNode.removeChild(containerDiv);
- containerDiv = childDiv = a = b = c = undefined;
- });
-
- setup(function() {
- containerDiv = document.createElement('div');
- childDiv = document.createElement('div');
- childDiv.innerHTML = 'abc';
- a = childDiv.firstChild;
- b = a.nextSibling;
- c = childDiv.lastChild;
- containerDiv.appendChild(childDiv);
- document.body.appendChild(containerDiv);
- });
-
- test('createTreeWalker with document', function() {
- var treeWalker = document.createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, null, null);
-
- assert.instanceOf(treeWalker,TreeWalker);
- assert.equal(TreeWalker, treeWalker.constructor);
-
- var found;
- while (treeWalker.nextNode()) {
- assert(isWrapper(treeWalker.currentNode));
- if (treeWalker.currentNode.hasAttribute("title")){
- found=treeWalker.currentNode.getAttribute("title")==='a';
- break;
- }
- }
- assert.isTrue(found);
- });
-
- test('createTreeWalker with wrapped document', function() {
- var treeWalker = wrap(document).createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, null);
-
- assert.instanceOf(treeWalker,TreeWalker);
- assert.equal(TreeWalker, treeWalker.constructor);
-
- var found;
- while (treeWalker.nextNode()) {
- assert(isWrapper(treeWalker.currentNode));
- if (treeWalker.currentNode.hasAttribute("title")){
- found=treeWalker.currentNode.getAttribute("title")==='a';
- break;
- }
- }
- assert.isTrue(found);
- });
-
- test('createTreeWalker returns wrapped nodes', function() {
- var treeWalker = document.createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, null);
-
- assert(isWrapper(treeWalker.root));
- assert(isWrapper(treeWalker.nextNode()));
- assert(isWrapper(treeWalker.parentNode()));
- assert(isWrapper(treeWalker.firstChild()));
- assert(isWrapper(treeWalker.lastChild()) ||
- isWrapper(treeWalker.lastChild())===null);
- assert(isWrapper(treeWalker.previousSibling()) ||
- isWrapper(treeWalker.previousSibling())===null);
- assert(isWrapper(treeWalker.previousNode()));
-
- });
-
- test('createTreeWalker with filter as object with acceptNode function', function() {
-
- // NodeFilter.acceptNode as filter does not work in IE.
- // https://dom.spec.whatwg.org/#nodefilter
- if (/Trident/.test(navigator.userAgent))
- return;
-
- var treeWalker = document.createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, {
- acceptNode:function(node){
- assert(isWrapper(node));
- if (node.hasAttribute("title") && node.getAttribute("title")==='a'){
- return NodeFilter.FILTER_ACCEPT;
- }
- return false;
- }
- });
-
- assert.isNotNull(treeWalker.filter);
- // in FF and IE treeWalker.filter is just a js object
- //assert.instanceOf(treeWalker.filter, NodeFilter);
-
- // we should have one node only.
- assert.isNotNull(treeWalker.nextNode());
- assert.isNull(treeWalker.nextNode());
-
- });
-
- test('createTreeWalker with filter as a function (works under IE and others)', function() {
-
- var treeWalker = document.createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, function(node){
- assert(isWrapper(node));
- if (node.hasAttribute("title") && node.getAttribute("title")==='a'){
- return NodeFilter.FILTER_ACCEPT;
- }
- return false;
- });
-
- assert.isNotNull(treeWalker.filter);
-
- // we should have one node only.
- assert.isNotNull(treeWalker.nextNode());
- assert.isNull(treeWalker.nextNode());
-
- });
-
- test('createTreeWalker with bogus filter', function() {
-
- var treeWalker = document.createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT, {});
-
- // we should have one node only.
- assert.isNotNull(treeWalker.nextNode());
- assert.isNotNull(treeWalker.nextNode());
- assert.isNotNull(treeWalker.nextNode());
- assert.isNull(treeWalker.nextNode());
-
- });
-
- test('get/set currentNode', function() {
-
- var treeWalker = wrap(document).createTreeWalker(childDiv, NodeFilter.SHOW_ELEMENT);
-
- assert(treeWalker.currentNode.isEqualNode(childDiv));
- assert(treeWalker.root.isEqualNode(childDiv));
-
- treeWalker.lastChild();
- assert(treeWalker.currentNode.isEqualNode(c));
-
-
- treeWalker.currentNode = a;
- assert(treeWalker.currentNode.isEqualNode(a));
- treeWalker.nextNode();
- assert(treeWalker.currentNode.isEqualNode(b));
-
- });
-
-});
diff --git a/tests/ShadowDOM/js/Window.js b/tests/ShadowDOM/js/Window.js
deleted file mode 100644
index c939095..0000000
--- a/tests/ShadowDOM/js/Window.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('Window', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
-
- test('addEventListener', function() {
- var calls = 0;
- var doc = wrap(document);
- var win = wrap(window);
- window.addEventListener('click', function f(e) {
- calls++;
- assert.equal(this, win);
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, this);
- window.removeEventListener('click', f);
- });
- win.addEventListener('click', function f(e) {
- calls++;
- assert.equal(this, win);
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, this);
- win.removeEventListener('click', f);
- });
-
- addEventListener('click', function f(e) {
- calls++;
- assert.equal(this, win);
- assert.equal(e.target, doc.body);
- assert.equal(e.currentTarget, this);
- removeEventListener('click', f);
- });
-
- document.body.click();
- assert.equal(3, calls);
-
- document.body.click();
- assert.equal(3, calls);
- });
-
- test('getComputedStyle', function() {
- var div = document.createElement('div');
- var cs = window.getComputedStyle(div);
- assert.isTrue(cs != null);
-
- div = document.createElement('div');
- cs = wrap(window).getComputedStyle(div);
- assert.isTrue(cs != null);
-
- div = document.createElement('div');
- cs = getComputedStyle(div);
- assert.isTrue(cs != null);
- });
-
- test('getComputedStyleShadow', function() {
- var host = document.createElement('div');
- var root = host.createShadowRoot();
- var elt = document.createElement('div');
- root.appendChild(elt);
- document.body.appendChild(host);
- elt.style.padding = '4px';
- assert.equal(getComputedStyle(elt).paddingLeft, '4px');
- document.body.removeChild(host);
- });
-
- test('instanceof', function() {
- var win = wrap(window);
- assert.instanceOf(win, Window);
- });
-
- test('constructor', function() {
- var win = wrap(window);
- assert.equal(Window, win.constructor);
- });
-
-});
diff --git a/tests/ShadowDOM/js/XMLHttpRequest.js b/tests/ShadowDOM/js/XMLHttpRequest.js
deleted file mode 100644
index b9697ca..0000000
--- a/tests/ShadowDOM/js/XMLHttpRequest.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('XMLHttpRequest', function() {
-
- var wrap = ShadowDOMPolyfill.wrap;
- var unwrap = ShadowDOMPolyfill.unwrap;
-
- test('instanceof', function() {
- var xhr = new XMLHttpRequest();
- assert.instanceOf(xhr, XMLHttpRequest);
- });
-
- test('send', function() {
- var xhr = new XMLHttpRequest();
- xhr.open('POST', location.href);
- xhr.send(new FormData());
- });
-
-});
diff --git a/tests/ShadowDOM/js/build-json.js b/tests/ShadowDOM/js/build-json.js
deleted file mode 100644
index e848234..0000000
--- a/tests/ShadowDOM/js/build-json.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-
-suite('build.json', function() {
-
- teardown(function() {
- delete document.write;
- });
-
- test('Ensure lists match', function(done) {
- var xhrJson = new XMLHttpRequest;
- // karma serves the test runner at /context.html, need to adjust xhr request url to match
- var requestBase = window.__karma__ ? '/base/ShadowDOM/' : '../';
- xhrJson.open('GET', requestBase + 'build.json');
- xhrJson.onload = function() {
- var buildJson = JSON.parse(xhrJson.responseText);
-
- var xhrJs = new XMLHttpRequest;
- xhrJs.open('GET', requestBase + 'shadowdom.js');
- xhrJs.onload = function() {
- var sources = [];
-
- document.write = function(s) {
- var path =
- s.slice(('
-
-
-
Reload this page and you should see a dialog saying "OK".
diff --git a/tests/ShadowDOM/manual/setDragImage.html b/tests/ShadowDOM/manual/setDragImage.html
deleted file mode 100644
index 31436a3..0000000
--- a/tests/ShadowDOM/manual/setDragImage.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
Drag the div below the image. When dragging the image should be used as the
-drag image.
-
-
-
-
-
-
diff --git a/tests/WeakMap/tests.html b/tests/WeakMap/tests.html
deleted file mode 100644
index d40426e..0000000
--- a/tests/WeakMap/tests.html
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-WeakMap tests
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/a1-define.html b/tests/WebComponents/html/a1-define.html
deleted file mode 100644
index 3242690..0000000
--- a/tests/WebComponents/html/a1-define.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
\ No newline at end of file
diff --git a/tests/WebComponents/html/a1-import.html b/tests/WebComponents/html/a1-import.html
deleted file mode 100644
index eefee81..0000000
--- a/tests/WebComponents/html/a1-import.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/tests/WebComponents/html/a1-instance.html b/tests/WebComponents/html/a1-instance.html
deleted file mode 100644
index c54f7ed..0000000
--- a/tests/WebComponents/html/a1-instance.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/WebComponents/html/a1-reference.html b/tests/WebComponents/html/a1-reference.html
deleted file mode 100644
index 28d7cf5..0000000
--- a/tests/WebComponents/html/a1-reference.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/tests/WebComponents/html/ce-import.html b/tests/WebComponents/html/ce-import.html
deleted file mode 100644
index ea367a7..0000000
--- a/tests/WebComponents/html/ce-import.html
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/ce-upgrade-order.html b/tests/WebComponents/html/ce-upgrade-order.html
deleted file mode 100644
index 36bbf27..0000000
--- a/tests/WebComponents/html/ce-upgrade-order.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
- Custom Element Upgrade Order
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/ce-upgradedocumenttree.html b/tests/WebComponents/html/ce-upgradedocumenttree.html
deleted file mode 100644
index bfdf8b6..0000000
--- a/tests/WebComponents/html/ce-upgradedocumenttree.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/dev-loader-swizzled.html b/tests/WebComponents/html/dev-loader-swizzled.html
deleted file mode 100644
index d9e243c..0000000
--- a/tests/WebComponents/html/dev-loader-swizzled.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/dev-loader.html b/tests/WebComponents/html/dev-loader.html
deleted file mode 100644
index 1ef370f..0000000
--- a/tests/WebComponents/html/dev-loader.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/dom.html b/tests/WebComponents/html/dom.html
deleted file mode 100644
index 7d32d7e..0000000
--- a/tests/WebComponents/html/dom.html
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
- WebComponents dom tests
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/element-import-a.html b/tests/WebComponents/html/element-import-a.html
deleted file mode 100644
index a3d5ee5..0000000
--- a/tests/WebComponents/html/element-import-a.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
diff --git a/tests/WebComponents/html/element-import-b.html b/tests/WebComponents/html/element-import-b.html
deleted file mode 100644
index d34c444..0000000
--- a/tests/WebComponents/html/element-import-b.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
diff --git a/tests/WebComponents/html/html-import-sandbox-iframe.html b/tests/WebComponents/html/html-import-sandbox-iframe.html
deleted file mode 100644
index 1b9c906..0000000
--- a/tests/WebComponents/html/html-import-sandbox-iframe.html
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/html-import-sandbox.html b/tests/WebComponents/html/html-import-sandbox.html
deleted file mode 100644
index 8416760..0000000
--- a/tests/WebComponents/html/html-import-sandbox.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/import-upgrade-order.html b/tests/WebComponents/html/import-upgrade-order.html
deleted file mode 100644
index c173f4d..0000000
--- a/tests/WebComponents/html/import-upgrade-order.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
diff --git a/tests/WebComponents/html/includes/strawkit.js b/tests/WebComponents/html/includes/strawkit.js
deleted file mode 100644
index 6fdc111..0000000
--- a/tests/WebComponents/html/includes/strawkit.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * @license
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
- * 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
- */
-Polymer = {
- register: function(inElement, inPrototype) {
- if (inElement === window) {
- return;
- }
- inPrototype.readyCallback = function() {
- var template = inElement.querySelector('template');
- if (template) {
- var root = this.createShadowRoot();
- root.appendChild(Platform.templateContent(template).cloneNode(true));
- }
- inPrototype.created.call(this);
- };
- inElement.register({
- prototype: inPrototype
- });
- }
-};
diff --git a/tests/WebComponents/html/jquery-shadowdom-polyfill.html b/tests/WebComponents/html/jquery-shadowdom-polyfill.html
deleted file mode 100644
index 883d01b..0000000
--- a/tests/WebComponents/html/jquery-shadowdom-polyfill.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
- ShadowDOM Polyfill + jQuery
-
-
-
-
-
-
asdf
-
-
-
diff --git a/tests/WebComponents/html/loader-forcepoly.html b/tests/WebComponents/html/loader-forcepoly.html
deleted file mode 100644
index 7704e1c..0000000
--- a/tests/WebComponents/html/loader-forcepoly.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/smoke.html b/tests/WebComponents/html/smoke.html
deleted file mode 100644
index dca9d76..0000000
--- a/tests/WebComponents/html/smoke.html
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- plain
-
-
-
-
diff --git a/tests/WebComponents/html/strawkit.html b/tests/WebComponents/html/strawkit.html
deleted file mode 100644
index 0198a2e..0000000
--- a/tests/WebComponents/html/strawkit.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- Strawkit Test
-
-
-
-
-
-
-
-
-
-
- If it's blue (), then IT LIVES!
-
-
-
-
-
-
diff --git a/tests/WebComponents/html/web-components.html b/tests/WebComponents/html/web-components.html
deleted file mode 100644
index 4fa060f..0000000
--- a/tests/WebComponents/html/web-components.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/WebComponents/runner.html b/tests/WebComponents/runner.html
deleted file mode 100644
index 5b6c824..0000000
--- a/tests/WebComponents/runner.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-WebComponents Tests
-
-
-
-
diff --git a/tests/WebComponents/html/ce-import-upgrade-async.html b/tests/ce-import-upgrade-async.html
similarity index 89%
rename from tests/WebComponents/html/ce-import-upgrade-async.html
rename to tests/ce-import-upgrade-async.html
index 122801a..2d846cc 100644
--- a/tests/WebComponents/html/ce-import-upgrade-async.html
+++ b/tests/ce-import-upgrade-async.html
@@ -12,8 +12,8 @@
-
-
+
+
-
-
+
+
+
diff --git a/tests/ce-import.html b/tests/ce-import.html
new file mode 100644
index 0000000..5200d32
--- /dev/null
+++ b/tests/ce-import.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/HTMLImports/html/encoding.html b/tests/ce-upgrade-order.html
similarity index 53%
rename from tests/HTMLImports/html/encoding.html
rename to tests/ce-upgrade-order.html
index 9eccf98..9777940 100644
--- a/tests/HTMLImports/html/encoding.html
+++ b/tests/ce-upgrade-order.html
@@ -11,17 +11,23 @@
-
-
-
-
+ Custom Element Upgrade Order
+
+
+
-
+
diff --git a/tests/ce-upgradedocumenttree.html b/tests/ce-upgradedocumenttree.html
new file mode 100644
index 0000000..d0429d5
--- /dev/null
+++ b/tests/ce-upgradedocumenttree.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/dev-loader-swizzled.html b/tests/dev-loader-swizzled.html
new file mode 100644
index 0000000..c6da9cf
--- /dev/null
+++ b/tests/dev-loader-swizzled.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/dev-loader.html b/tests/dev-loader.html
new file mode 100644
index 0000000..0c02c8c
--- /dev/null
+++ b/tests/dev-loader.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/WebComponents/html/element-import.html b/tests/imports/a1-define.html
similarity index 56%
rename from tests/WebComponents/html/element-import.html
rename to tests/imports/a1-define.html
index da6c75c..7b88009 100644
--- a/tests/WebComponents/html/element-import.html
+++ b/tests/imports/a1-define.html
@@ -7,15 +7,26 @@
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
-->
-
diff --git a/tests/imports/a1-import.html b/tests/imports/a1-import.html
new file mode 100644
index 0000000..6b0a1e0
--- /dev/null
+++ b/tests/imports/a1-import.html
@@ -0,0 +1,11 @@
+
+
+
diff --git a/tests/imports/a1-instance.html b/tests/imports/a1-instance.html
new file mode 100644
index 0000000..0864bc5
--- /dev/null
+++ b/tests/imports/a1-instance.html
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/tests/imports/a1-reference.html b/tests/imports/a1-reference.html
new file mode 100644
index 0000000..908edc9
--- /dev/null
+++ b/tests/imports/a1-reference.html
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/tests/HTMLImports/html/imports/csp-import-1.html b/tests/imports/csp-import-1.html
similarity index 100%
rename from tests/HTMLImports/html/imports/csp-import-1.html
rename to tests/imports/csp-import-1.html
diff --git a/tests/HTMLImports/html/imports/csp-import-2.html b/tests/imports/csp-import-2.html
similarity index 100%
rename from tests/HTMLImports/html/imports/csp-import-2.html
rename to tests/imports/csp-import-2.html
diff --git a/tests/HTMLImports/html/imports/csp-script-1.js b/tests/imports/csp-script-1.js
similarity index 100%
rename from tests/HTMLImports/html/imports/csp-script-1.js
rename to tests/imports/csp-script-1.js
diff --git a/tests/HTMLImports/html/imports/csp-script-2.js b/tests/imports/csp-script-2.js
similarity index 100%
rename from tests/HTMLImports/html/imports/csp-script-2.js
rename to tests/imports/csp-script-2.js
diff --git a/tests/HTMLImports/html/imports/current-script.js b/tests/imports/current-script.js
similarity index 93%
rename from tests/HTMLImports/html/imports/current-script.js
rename to tests/imports/current-script.js
index 029af75..402c32c 100644
--- a/tests/HTMLImports/html/imports/current-script.js
+++ b/tests/imports/current-script.js
@@ -10,4 +10,4 @@
remoteCurrentScriptExecuted = window.remoteCurrentScriptExecuted || 0;
remoteCurrentScriptExecuted++;
-chai.assert.ok(document._currentScript);
+assert.ok(document._currentScript);
diff --git a/tests/imports/element-import-a.html b/tests/imports/element-import-a.html
new file mode 100644
index 0000000..775c360
--- /dev/null
+++ b/tests/imports/element-import-a.html
@@ -0,0 +1,11 @@
+
+
+
diff --git a/tests/imports/element-import-b.html b/tests/imports/element-import-b.html
new file mode 100644
index 0000000..a48c169
--- /dev/null
+++ b/tests/imports/element-import-b.html
@@ -0,0 +1,11 @@
+
+
+
diff --git a/tests/Template/runner.html b/tests/imports/element-import.html
similarity index 58%
rename from tests/Template/runner.html
rename to tests/imports/element-import.html
index 976a80e..6b8935f 100644
--- a/tests/Template/runner.html
+++ b/tests/imports/element-import.html
@@ -1,24 +1,20 @@
-
-Template Tests
-
-
-
-
+
diff --git a/tests/WebComponents/html/includes/import-file.html b/tests/imports/import-file.html
similarity index 100%
rename from tests/WebComponents/html/includes/import-file.html
rename to tests/imports/import-file.html
diff --git a/tests/imports/import-upgrade-order.html b/tests/imports/import-upgrade-order.html
new file mode 100644
index 0000000..fb88f66
--- /dev/null
+++ b/tests/imports/import-upgrade-order.html
@@ -0,0 +1,10 @@
+
+
diff --git a/tests/HTMLImports/html/imports/script-1.html b/tests/imports/script-1.html
similarity index 79%
rename from tests/HTMLImports/html/imports/script-1.html
rename to tests/imports/script-1.html
index 259f79b..dedaaee 100644
--- a/tests/HTMLImports/html/imports/script-1.html
+++ b/tests/imports/script-1.html
@@ -10,7 +10,7 @@
me
-
\ No newline at end of file
+
diff --git a/tests/HTMLImports/html/imports/script-2.html b/tests/imports/script-2.html
similarity index 82%
rename from tests/HTMLImports/html/imports/script-2.html
rename to tests/imports/script-2.html
index 234c1d6..78d878a 100644
--- a/tests/HTMLImports/html/imports/script-2.html
+++ b/tests/imports/script-2.html
@@ -10,6 +10,6 @@
me2
-
\ No newline at end of file
+
diff --git a/tests/imports/simple-element.html b/tests/imports/simple-element.html
new file mode 100644
index 0000000..8384ce8
--- /dev/null
+++ b/tests/imports/simple-element.html
@@ -0,0 +1,38 @@
+
+
+
diff --git a/tests/integration.html b/tests/integration.html
new file mode 100644
index 0000000..36827b8
--- /dev/null
+++ b/tests/integration.html
@@ -0,0 +1,61 @@
+
+
+
+
+ Template with HTMLImports Test
+
+
+
+
+
+
+
+ Light DOM
+
+
+
+
diff --git a/tests/load.html b/tests/load.html
new file mode 100644
index 0000000..67dcb1e
--- /dev/null
+++ b/tests/load.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/runner.html b/tests/runner.html
index b93b5a0..d892efb 100644
--- a/tests/runner.html
+++ b/tests/runner.html
@@ -15,17 +15,18 @@
diff --git a/tests/smoke.html b/tests/smoke.html
new file mode 100644
index 0000000..465f6ca
--- /dev/null
+++ b/tests/smoke.html
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+ plain
+
+
+
+
diff --git a/tests/Template/customElements.html b/tests/template-and-CE.html
similarity index 51%
rename from tests/Template/customElements.html
rename to tests/template-and-CE.html
index 05b43b4..5613919 100644
--- a/tests/Template/customElements.html
+++ b/tests/template-and-CE.html
@@ -11,9 +11,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
Template with HTMLImports Test
-
-
-
+
+
+
@@ -21,36 +21,47 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
-
-
-
-
+
+
+
+
-
+
+
-
+
-
+
-
+
');
- });
-
- // exports
- WebComponents.flags = flags;
-
-})();
diff --git a/workbench/ie10-task-flaking.html b/workbench/ie10-task-flaking.html
deleted file mode 100644
index c64b300..0000000
--- a/workbench/ie10-task-flaking.html
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
- MutationObserver
-
-
-
-
-
-
MutationObserver test page
-
-
Clicking start will schedule two self-restarting functions:
-
-
runSetTimeout uses setTimeout(fn, 0) for queueing itself
-
runMutation uses a MutationObserver for queueing itself
-
-
-
-After starting the test, move your mouse so that it is hovering over the top line of output.
-
-
-
-If the browser is behaving, you should see runSetTimeout calls interleaved with runMutation calls (either 2:1 or 1:1, depending).
-
-
-
-On IE10, if our MutationObserver polyfill uses setImmediate, postMessage, or MessageQueue, the runMutation line will become erratic, and eventually not fire at all.
-