diff --git a/dist/aframe-v0.1.2.js b/dist/aframe-v0.1.2.js new file mode 100644 index 00000000000..1354ebbca31 --- /dev/null +++ b/dist/aframe-v0.1.2.js @@ -0,0 +1,60287 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AFRAME = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o`. + prototype: Object.create( + HTMLTemplateElement.prototype, + { + createdCallback: { + value: function () { + var self = this; + self.placeholders = []; + // For Chrome: https://github.com/aframevr/aframe-core/issues/321 + window.addEventListener('load', function () { + appendElement(); + function appendElement () { + var isInDocument = self.ownerDocument === document; + // TODO: Handle `` from imported templates for Chrome. + if (!isInDocument) { document.body.appendChild(self); } + } + }); + }, + writable: window.debug + }, + + attachedCallback: { + value: function () { + this.load(); + this.inject(); + }, + writable: window.debug + }, + + detachedCallback: { + value: function () { + // XXX: Hack for VS to hide templates from source. + // var self = this; + // self.removeTemplateListener(); + // self.placeholders.forEach(function (el) { + // self.sceneEl.remove(el); + // }); + }, + writable: window.debug + }, + + load: { + value: function () { + // To prevent emitting the loaded event more than once. + if (this.hasLoaded) { return; } + utils.fireEvent(this, 'loaded'); + this.hasLoaded = true; + }, + writable: window.debug + }, + + register: { + value: function (tagName) { + if (this.registered) { return; } + this.registered = true; + return registerTemplate(tagName); + }, + writable: window.debug + }, + + removeTemplateListener: { + value: function () { + if (!this.mixinObserver) { return; } + this.mixinObserver.disconnect(); + this.mixinObserver = null; + }, + writable: window.debug + }, + + attachTemplateListener: { + value: function (tagName) { + var self = this; + if (self.mixinObserver) { self.mixinObserver.disconnect(); } + self.mixinObserver = new MutationObserver(function (mutations) { + self.placeholders.forEach(function (el) { + el.rerender(true); + }); + }); + self.mixinObserver.observe(self, { + attributes: true, + characterData: true, + childList: true, + subtree: true + }); + }, + writable: window.debug + }, + + inject: { + value: function () { + var self = this; + + if (self.injected) { return; } + self.injected = true; + + var tagName = self.getAttribute('element'); + if (!tagName) { return; } + + self.attachTemplateListener(tagName); + self.register(tagName); + }, + writable: window.debug + } + } + ) + } +); + +},{"../lib/vendor/HTMLImports":29,"./lib/register-template":12,"./lib/utils":13,"aframe-core":81}],11:[function(require,module,exports){ +var modules = { + 'a-event': require('./a-event'), + 'a-template': require('./a-template') +}; + +// This injects the template definitions into the page. +require('./templates/index.html'); + +module.exports = modules; + +},{"./a-event":9,"./a-template":10,"./templates/index.html":27}],12:[function(require,module,exports){ +var aframeCore = require('aframe-core'); +var utils = require('./utils'); + +var registerElement = aframeCore.registerElement.registerElement; +var AEntity = aframeCore.AEntity; +var AComponents = aframeCore.AComponents; + +var ATTRIBUTE_BLACKLIST = utils.extend({ + id: true, + name: true, + class: true, + target: true +}); +var COMPONENT_BLACKLIST = utils.extend({}, AComponents); + +registerElement('a-root', {prototype: Object.create(AEntity.prototype)}); + +module.exports = function (tagName) { + var tagNameLower = tagName.toLowerCase(); + + return registerElement( + tagNameLower, + { + prototype: Object.create( + AEntity.prototype, { + attachedCallback: { + value: function () { + // We emit an event so `` knows when we've been + // registered and adds our children as `object3D`s. + this.emit('loaded'); + this.emit('nodeready'); + this.rerender(false, true); + } + }, + + attributeChangedCallback: { + value: function (attr, oldVal, newVal) { + if (oldVal === newVal) { return; } + this.rerender(); + }, + writable: window.debug + }, + + attributeBlacklist: { + value: ATTRIBUTE_BLACKLIST, + writable: window.debug + }, + + componentBlacklist: { + value: COMPONENT_BLACKLIST, + writable: window.debug + }, + + detachedCallback: { + value: function () { + if (!this.sceneEl) { + this.sceneEl = utils.$('a-scene'); + } + this.sceneEl.remove(this); + }, + writable: window.debug + }, + + rerender: { + value: function (force, firstTime) { + var self = this; + if (!force && this.lastOuterHTML === this.outerHTML) { return; } + var template = utils.$('template[is="a-template"][element="' + tagName + '"]'); + if (!template) { return; } + + // Use the defaults defined on the original `