javascript-一个模块的Dojo构建失败:OPTIMIZER FAILED:InternalError:之后缺少名称.运算符

我使用Dojo Build工具成功构建了我的项目.但是,我有一个模块squad_builder / Pilot,无论何时将其包含在内,都会导致构建失败,并出现以下错误:

error(356) The optimizer threw an exception; the module probably contains syntax errors. module identifier: /Users/ferg/Dropbox/webdev/x-wing_squadron_builder/www/js/dist/squad_builder/run_deps.js; exception: (compile time:1.247s). OPTIMIZER FAILED: InternalError: missing name after . operator

该模块在开发中运行良好,甚至可以通过JS Lint运行它,其中没有明显的错误,特别是与放错位置的“”无关.我可以在任何地方看到.

这是模块的代码:

define( [ 'dojo/_base/declare', 

          // parents
          'dijit/TitlePane',

          // used modules
          'dojo/_base/lang',
          'dojo/_base/array',
          'dojo/dom-construct',
          'dojo/dom-style',
          'dojo/_base/fx',
          'dojo/_base/event',
          'squad_builder/actionIconParser',
          'dojo/promise/all',
          'dojo/Deferred',

          // dijits
          'dijit/form/Button',

          // stores
          // @todo only load rebels or empire store
          'squad_builder/storeBroker!rebelsStore',
          'squad_builder/storeBroker!empireStore',
          'squad_builder/storeBroker!actionsStore',
          'squad_builder/storeBroker!upgradeTypesStore',
          'squad_builder/storeBroker!setsStore',
          'squad_builder/storeBroker!shipTypesStore',

          // template
          'dojo/text!./Pilot/templates/Pilot.html' // extended TitlePane template

    ],
    function( declare, 
        TitlePane, 
        lang, array, domConstruct, domStyle, fx, event, actionIconParser, all, Deferred, 
        Button, 
        rebelsStore, empireStore, actionsStore, upgradeTypesStore, setsStore, shipTypesStore,
        template )
    {
        return declare( [ TitlePane ], 
        {
            // provided to constructor
            faction: null,

            pilotId: null,
            squadList: null,
            squadPaneId: null, // used for duplicating

            basePoints: null, // initial points
            points: null, // total points of pilot + upgrades

            _loaded: false, // flag to prevent multiple startup() calles

            allUpgradesLoaded: false,

            templateString: template,

            // A class to be applied to the root node in our template
            baseClass: 'pilotWidget dijitTitlePane',

            // used in auto-generated IDs
            declaredClass: 'squad_builder.PilotWidget',

            constructor: function()
            {
                // declared in constructor so all instances have their own copy
                this.pilotData = {};
                this.originalPilotData = {}; // used when removing upgrades so we cannot remove boost from A-Wings for example
                this.initiallySelectedUpgrades = [];
                this.upgradeButtons = [];

                // reference to squad-level caches
                this.uniqueUpgradeCache = {}; 
                this.collection = null;
            },

            // fetch the pilot data before loading template
            postMixInProperties: function()
            {
                this.inherited( arguments );

                // use pilot id to load the rest of the pilot data
                var store = this.faction == 'rebels' ? rebelsStore : empireStore,
                    data = store.get( this.pilotId ); // pilot data

                // save pilot data
                lang.mixin( this.pilotData, lang.clone( data ) ); // bugfix: needs clone or all copies of this ship will be modified by pilot modules
                this.originalPilotData = lang.clone( this.pilotData );

                // set initial points
                this.basePoints = parseInt( this.pilotData.cost ); // base points = pilot cost
                this.points = parseInt( this.pilotData.cost ); // may increase with upgrades
            },          

            postCreate: function()
            {
                // Run any parent postCreate processes - can be done at any point
                this.inherited( arguments );

                // wait until we have child widgets containing upgrades before figuring out points
                this._calculatePoints();

                // info
                this.infoDiv.innerHTML = shipTypesStore.get( this.pilotData.ship_type_id )['name'];

                if( this.pilotData.unique  )
                {
                    this.infoDiv.innerHTML += ', Unique';
                }

                if( !this.pilotData.released )
                {
                    this.infoDiv.innerHTML +=  ', Unreleased';
                }

                // switch between energy and primary stats
                if( !this.pilotData.energy )
                {
                    domStyle.set( this.energyNode, { display: 'none' } );
                }

                if( !this.pilotData.primary )
                {
                    domStyle.set( this.primaryNode, { display: 'none' } );
                }

                // ability
                if( this.pilotData.ability )
                {
                    this.abilityDiv.innerHTML = actionIconParser( this.pilotData.ability );
                }

                // add icons for actions
                this._initActions();

                // sets
                array.forEach( this.pilotData.sets, function( set )
                {
                    var setData = setsStore.get( set );
                    domConstruct.create( 'div',
                    {
                        innerHTML: setData.acronym,
                        title: setData.name
                    },
                    this.setsContainer );
                }, this );

                // clear message if any upgrades
                if( this.pilotData.upgrades.length )
                {
                    this.upgradesDiv.innerHTML = '';
                }
            },

            /*
             * Upgrades added here or watch() doesn't fire!
             */
            startup: function()
            {
                if( this._loaded == false ) // only call this once when first adding pilot, not again when sorting
                {
                    // track all upgrades
                    var allUpgradesLoadedPromises = [];

                    // upgrade buttons
                    array.forEach( this.pilotData.upgrades, function( upgradeTypeId, index )
                    {
                        var deferred = this._addUpgradeButton( upgradeTypeId, this.initiallySelectedUpgrades[ index ], index, false );
                        allUpgradesLoadedPromises.push( deferred.promise );
                    },
                    this );

                    // do we have extra upgrades (eg. added by another upgrade)?
                    var extraUpgrades = array.filter( this.initiallySelectedUpgrades, function( selectedUpgrade )
                    {
                        return selectedUpgrade instanceof Array;
                    } );

                    if( extraUpgrades.length > 0 )
                    {
                        array.forEach( extraUpgrades, function( extraUpgrade, index )
                        {
                            var deferred = this._addUpgradeButton( extraUpgrade[1], extraUpgrade[0], this.pilotData.upgrades.length + index, true );
                            allUpgradesLoadedPromises.push( deferred.promise );
                        },
                        this );
                    }

                    // track when all promises fulfilled
                    // other objects (eg. modules) can use watch('allUpgradesLoaded') to hook into this
                    all( allUpgradesLoadedPromises ).then( lang.hitch( this, function()
                    {
                        this.set( 'allUpgradesLoaded', true );
                    } ) ).otherwise( function()
                    {
                        console.warn( 'Failed to track whether upgrades loaded', arguments );
                    } );

                    // highlight
                    domStyle.set( this.containerNode, { backgroundColor: '#FFF8B5' } );
                    fx.animateProperty(
                    {
                        node: this.containerNode,
                        properties: {
                            backgroundColor: '#FFFFFF'
                        },
                        duration: 500,
                        delay: 1000
                     } ).play();

                    this._loaded = true;
                }
            },

            _initActions: function()
            {
                // show action icons    
                // in function so we can fade out old icons first...
                var show = lang.hitch( this, function()
                {
                    domStyle.set( this.actionsDiv, 'opacity', 0 );

                    array.forEach( this.pilotData.actions, function( action )
                    {
                        var actionData = actionsStore.get( action );

                        domConstruct.create( 'div',
                        {
                            className: 'icon_action ' + actionData.class_name,
                            title: actionData.name
                        },
                        this.actionsDiv );
                    },
                    this );

                    fx.fadeIn(
                    {
                        node: this.actionsDiv
                    } ).play();
                } );

                // already got icons?
                if( this.actionsDiv !== undefined && this.actionsDiv.innerHTML != '' )
                {
                    fx.fadeOut(
                    {
                        node: this.actionsDiv,
                        onEnd: lang.hitch( this, function()
                        {
                            this.actionsDiv.innerHTML = '';
                            show();
                        } )
                    } ).play();
                }   
                else
                {
                    show();
                }   
            },

            _addUpgradeButton: function( upgradeTypeId, selectedId, position, isExtra ) 
            {
                var upgradeTypeData = upgradeTypesStore.get( upgradeTypeId ), // type of upgrade tells us what upgrade store to use
                    upgradeButtonDeferred = new Deferred();

                // get specific upgrade data for this button
                require( [ 'squad_builder/PilotUpgradeButton', 'squad_builder/storeBroker!' + upgradeTypeData.store ], 
                    lang.hitch( this, function( PilotUpgradeButton, upgradeStore )
                {
                    // create button
                    var upgradeButton = new PilotUpgradeButton(
                    {
                        position: position,
                        isExtra: Boolean( isExtra ),
                        pilot: this,
                        upgradeTypeId: upgradeTypeId,
                        name: upgradeTypeData.name,
                        upgradeClass: upgradeTypeData.class,
                        upgradeStore: upgradeStore,
                        selectedId: selectedId, 

                        // reference to squadlist-level cache
                        // used to check if unique upgrades used
                        uniqueUpgradeCache: this.uniqueUpgradeCache,

                        // reference to squadpane-level collection store
                        // used to record component use
                        collection: this.collection
                    } );

                    // watch points changes
                    upgradeButton.watch( 'points', lang.hitch( this, function()
                    {
                        this._calculatePoints();
                    } ) );

                    // store reference
                    this.upgradeButtons.push( upgradeButton );

                    // place
                    upgradeButton.placeAt( this.upgradesDiv );
                    upgradeButton.startup(); // add upgrades after watch() added

                    upgradeButtonDeferred.resolve( upgradeButton );
                } ) );

                return upgradeButtonDeferred; // allows pilot._addUpgradeButton( ... ).then( ... )
            },

            _calculatePoints: function()
            {
                var points = this.get('basePoints');

                // get points from upgrade buttons
                array.forEach( this.upgradeButtons, function( upgradeButton )
                {
                    points += upgradeButton.get( 'points' );
                } );

                this.set( 'points', points );
            },

            _calculateTitle: function()
            {
                var title = this.pilotData.name;
                array.forEach( this.upgradeButtons, function( upgradeButton )
                {
                    var upgradeName = upgradeButton.get( 'selectedName' );
                    if( upgradeName )
                    {
                        title += ' + ' + upgradeName;
                    }   
                } );
                title += ' (' + this.get( 'points' ) + ')';

                this.set( 'title', title );
            },

            // for dojo/Stateful watch/get/set
            _setPointsAttr: function( value ) 
            {
                this._set( 'points', value );
                this._calculateTitle();
            },

            close: function()
            {
                this.set( 'open', false );
            },

            _onDelete: function( e )
            {
                event.stop( e );
                this.onDelete();
                this.destroyRecursive();
            },

            /**
             * Extension point
             */
            onDelete: function()
            {
            },

            _onDuplicate: function( e )
            {
                event.stop( e );
                this.onDuplicate();
                this.squadList.addPilot( this.get( 'squadPaneId' ), this.get('faction'), this.get('pilotId'), this.get('upgrades')  );
            },

            /**
             * Extension point
             */
            onDuplicate: function()
            {
            },

            _onMoveUp: function( e )
            {
                event.stop( e );
                this.onMoveUp();
                this.squadList.movePilot( this.get( 'id' ), -1  );
            },

            /**
             * Extension point
             */
            onMoveUp: function()
            {
            },

            _onMoveDown: function( e )
            {
                event.stop( e );
                this.onMoveDown();
                this.squadList.movePilot( this.get( 'id' ), 1  );
            },

            /**
             * Extension point
             */
            onMoveDown: function()
            {
            },

            /**
             * Data to save/recreate this pilot
             */
            getData: function()
            {
                return { 
                    id: this.get('pilotId'), 
                    points: this.get('points'), 
                    basePoints: this.get('basePoints'), 
                    upgrades: this.get('upgrades') 
                };
            },

            /**
             * allows: this.get('upgrades')
             */
            _getUpgradesAttr: function()
            {
                // get upgrades from buttons
                var upgrades = [];

                // upgradeButton widgets may not be instantiated when this.get('upgrades') first called 
                // if so default to...
                if( this.upgradeButtons.length == 0 ) 
                {
                    // ... initially selected upgrades
                    if( this.initiallySelectedUpgrades.length !== undefined && this.initiallySelectedUpgrades.length > 0 ) 
                    {
                        upgrades = this.initiallySelectedUpgrades;
                    }
                    // ... or create array of nulls
                    else 
                    {   
                        var numUpgrades = this.pilotData.upgrades.length,
                            i = 0;
                        while( i++ < numUpgrades )
                        {
                            upgrades.push( null );
                        }
                    }
                }
                else
                {
                    array.forEach( this.upgradeButtons, function( upgradeButton )
                    {
                        // use position from instantiation to ensure we get them in the right order
                        upgrades[ upgradeButton.get( 'position' ) ] = upgradeButton.get( 'selectedId' ); // id or null or tuple pair
                    } );
                }

                return upgrades;
            },

            _getNameAttr: function()
            {
                return this.pilotData.name;
            },

            _getPilotAttr: function()
            {
                return this.pilotData.pilot;
            },

            _setPilotAttr: function( value )
            {
                this.pilotData.pilot = value;

                // animate change
                fx.fadeOut(
                {
                    node: this.pilotNode,
                    onEnd: lang.hitch( this, function()
                    {
                        this.pilotNode.innerHTML = value;
                        fx.fadeIn(
                        {
                            node: this.pilotNode
                        } ).play();
                    } )
                } ).play();
            },

            _getShieldsAttr: function()
            {
                return this.pilotData.shields;
            },

            _setShieldsAttr: function( value )
            {
                this.pilotData.shields = value;

                // animate change
                var shieldsNode = this.shieldsNode; // was losing scope so use local var
                fx.fadeOut(
                {
                    node: shieldsNode,
                    onEnd: function()
                    {
                        shieldsNode.innerHTML = value;
                        fx.fadeIn(
                        {
                            node: shieldsNode
                        } ).play();
                    }
                } ).play();
            },

            _getAgilityAttr: function()
            {
                return this.pilotData.agility;
            },

            _setAgilityAttr: function( value )
            {
                this.pilotData.agility = value;

                // animate change
                fx.fadeOut(
                {
                    node: this.agilityNode,
                    onEnd: lang.hitch( this, function()
                    {
                        this.agilityNode.innerHTML = value;
                        fx.fadeIn(
                        {
                            node: this.agilityNode
                        } ).play();
                    } )
                } ).play();
            },

            _getHullAttr: function()
            {
                return this.pilotData.hull;
            },

            _setHullAttr: function( value )
            {
                this.pilotData.hull = value;

                // animate change
                fx.fadeOut(
                {
                    node: this.hullNode,
                    onEnd: lang.hitch( this, function()
                    {
                        this.hullNode.innerHTML = value;
                        fx.fadeIn(
                        {
                            node: this.hullNode
                        } ).play();
                    } )
                } ).play();
            },

            _getEnergyAttr: function()
            {
                return this.pilotData.energy;
            },

            _setEnergyAttr: function( value )
            {
                this.pilotData.energy = value;

                // animate change
                fx.fadeOut(
                    {
                        node: this.energyNode,
                        onEnd: lang.hitch( this, function()
                        {
                            this.energyNode.innerHTML = value;
                            fx.fadeIn(
                            {
                                node: this.energyNode
                            } ).play();
                        } )
                    } ).play();
            }

        } );
    } 
);

我已经遍历过代码,但是我找不到任何看起来与我收到的错误消息匹配的东西.有任何想法吗?

解决方法:

我遇到此错误是因为我使用JavaScript关键字作为对象属性.例如:

object.return.value而不是object [‘return’].value

原文地址:https://codeday.me/bug/20191029/1959844.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易知道用户保存了什么,我希望当用户第一次看到网格时,网格处于不可编辑状态.当用户准备好后,他们可以单击编辑按钮,这将使网格的某些部分可编辑.然后,有一个保存或取消按钮可以保存更改或还原.在大多数情况下它是有效的.但
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以轻松打包为Web,Mobiles和可能的Standalone版本的方式来实现这一目标.我不想使用Flash.因此,我确信(无论如何我会听取建议)使用JavaScript和SVG.我正在对这个问题进行大量研究,但我很难把各个部分放在一起.我知道Raphae
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部件–我在表单中使用–将固定格式(JavaScript基本格式)的实数值(例如:12.56)设置为HTML表单输入字段(但根据浏览器区域设置显示/编辑它们,所以用户总是看到格式正确的数字).另一方面,Grails期望输入字段根据浏览器
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforjavaScript的学习历程,本篇将从最开始的arcgisapiforjavaScript部署开始,个人声明:博文不在传道受业解惑,旨在方便日后复习查阅。由于是自学,文章中可能会出现一些纰漏,请留言指出,不必留有情面哦!2.下载ArcGISforDe
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑:Thedeclarefunctionisdefinedinthedojo/_base/declaremodule.declareacceptsthreearguments:className,superClass,andproperties.ClassNameTheclassNameargumentrepresentsthenameofthec
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这个问题曾多次被问到,但为了弄清楚我的事实,我需要澄清一些事情,因为我在客户端技术方面的经验非常有限.我们决定使用GWT而不是纯JavaScript框架构建我们的解决方案(假设有更多的Java经验).这些是支持我的决定的事实.>
路由dojo/framework/srcouting/README.mdcommitb682b06ace25eea86d190e56dd81042565b35ed1Dojo应用程序的路由路由FeaturesRoute配置路径参数RouterHistoryManagersHashHistoryStateHistoryMemoryHistoryOutletEventRouterContextInjectionOutl
请原谅我的无知,因为我对jquery并不熟悉.是否有dojo.connect()的等价物?我找到了这个解决方案:http:/hink-robot.com/2009/06/hitch-object-oriented-event-handlers-with-jquery/但是没有断开功能!你知道jquery的其他解决方案吗?有jquery.connect但这个插件在我的测试中不起作用.
与java类一样,在dojo里也可以定义constructor 构造函数,在创建一个实例时可以对需要的属性进行初始化。//定义一个类mqsy_yjvar mqsy_yj=declare(null,{     //thedefaultusername    username: "yanjun",          //theconstructor   
我一直在寻找一些最佳实践,并想知道Dojo是否具有框架特定的最佳实践,还是最好只使用通用的Javascript标准?特别是我主要是寻找一些功能和类评论的指导方针?解决方法:对于初学者来说,这是项目的风格指南:DojoStyleGuide
我有’05/17/2010’的价值我想通过使用dojo.date.locale将其作为“2010年5月17日”.我尝试过使用dojo.date.locale.parse,如下所示:x='05/17/2010'varx=dojo.date.locale.parse(x,{datePattern:"MM/dd/yyyy",selector:"date"});alert(x)这并没有给我所需的日期
我正在尝试创建一个包含函数的dojo类,这些函数又调用此类中的其他函数,如下所示:dojo.provide("my.drawing");dojo.declare("my.drawing",null,{constructor:function(/*Object*/args){dojo.safeMixin(this,args);this.container=args[0];
我知道你可以使用jQuery.noConflict为jQuery做这件事.有没有办法与Dojo做类似的事情?解决方法:我相信你可以.有关在页面上运行多个版本的Dojo,请参阅thispage.它很繁琐,但似乎是你正在寻找的东西.一般来说,Dojo和jQuery都非常小心,不会破坏彼此或其他任何人的变量名.
我有一个EnhancedGrid,用户经常使用复杂的过滤器.有没有办法允许用户保存或标记过滤器,以便将来可以轻松地重新应用它?我知道我可以通过编程方式设置过滤器,但我无法预测用户想要的过滤器.谢谢!编辑:自己做了一些进展…使用grid.getFilter()返回过滤器的JSON表示,然后使用json.strin
我有这个代码:dojo.declare("City",null,{constructor:function(cityid,cityinfo){}});dojo.declare("TPolyline",GPolyline,{constructor:function(points,color){},initialize:function(map){});应该是什
我遇到的问题是我的所有javascript错误似乎来自dojo.xd.js或子模块.我正在使用chrome调试器和许多dijit功能,如dijit.declaration和dojo.parser.这有点烦人,因为它很难找到简单的错误或滑倒.我希望我可以添加一个选项,允许我的调试器在我的非dojo代码中显示选项会发生的位置.我是
我正在使用DojoToolkit数字/解析函数来处理格式化和使用ICU模式语法解析字符串.有没有人知道有可能采取任意ICU模式字符串并以某种方式使用Dojo(或其他)库将其分解为它的部分(例如,对于数字模式,它可以被分解为小数位数,数千个分组等…).我希望这样做,而不需要让我的代码密切了
我有两个看似相关的问题,访问在不同的地方定义的javascript函数.我遇到的第一个问题是调用我在firgbug或safari控制台中定义的函数.我定义了一个名为getRed的函数,如下所示:functiongetRed(row,col){//dosomethingstuffandreturntheredvalueasa
我想添加一个在Ajax调用中指定的外部样式表.我已经找到了一种方法来使用jQuery(参见下面的示例),但是我需要使该方法适应dojoJavaScript框架.JQuery示例$('head').append('<linkrel="stylesheet"type="text/css"href="lightbox_stylesheet.css">');谢谢.解决方法:一旦你
我正在尝试使用dojo.connect将onMouseDown事件连接到图像,如:dojo.connect(dojo.byId("workpic"),"onMouseDown",workpicDown);functionworkpicDown(){alert("mousedown");}类似的代码几行后,我将onMouse*事件连接到dojo.body确实完全正常工作.但是当我点击图像时