I just wrote a "ready" routine for a custom element.
When the "ready" routine is called, "this.shadowRoot" points to the 
shadowRoot 
and the routine can access the global (polymer-element attributes) values.

At the end of the "ready" routine a call is made to a routine that appears 
above ready-routine.
In that routine it tries to access the global values.  In the debugger they 
are all undefined.
>From what I can tell, the "this" points to new window that does not have 
any of the variables
that the ready routine used and created.

I get an error saying you can not call <xxxx> on undefined.
But if I copy the contents from the routine, to just below the call, and 
comment out the call
everything works correctly. 

The sub-function is part of the elements "script" contents but is not a 
part of the global options.
I don't want to clutter all of the dependent functions of the element as 
global functions. This should not be necessary. 


here are some snippets of the code:

---------------------------------------------------------------

       var update_entire_line = function ()
          {
             my_debug('update_entire_line');
             var lrecl = this.lrecl;
             this.lcol.innerHTML  = this.lc_text;
             this.caret.innerHTML = this.cc_text;
             this.rcol.innerHTML  = this.rc_text;
          };

.................... 

          var initialize_listeners = function ()
          {
             my_debug('initialize_listners');


             var my_doc  = this.shadowRoot;
             this._root  = this.shadowRoot;
             var init_text = this.value;

             if ( init_text == null )
             {
                init_text = '';
             }

             this.lcol   =  my_doc.getElementById('left_col');
             this.caret  =  my_doc.getElementById('caret');
             this.rcol   =  my_doc.getElementById('right_col');

             this.caps_lock = false;
             this.shift_key = false;

             this.lc_text = this.lcol.innerHTML;
             this.cc_text = this.caret.innerHTML;
             this.rc_text = init_text;

             this.lc_len = this.lc_text.length
             this.cc_len = this.cc_text.length
             this.rc_len = this.rc_text.length
             console.log('calling initialize_listeners');
             var lrecl = this.lrecl;

             var it_len = init_text.length
             if ( it_len < lrecl )
             {
                var fill_cnt = lrecl - it_len + 1;
                console.log('fill: '+fill_cnt);
                this.rc_text = init_text + Array(fill_cnt).join(" ");
                this.rc_len = lrecl;
             }

    //         update_entire_line();
             this.lcol.innerHTML  = this.lc_text;
             this.caret.innerHTML = this.cc_text;
             this.rcol.innerHTML  = this.rc_text;

             var ln = my_doc.getElementById('entire_line');
             ln.addEventListener('keydown', key_down, false);
             ln.addEventListener('click', mouse_click, false);

          };
------------------------------------------------------------------------------------------


Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/a977b028-bcd5-492b-9827-e112027725a2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to