alchaplinsky / polymer-elements-rails

Polymer elements for Rails
https://elements.polymer-project.org/
MIT License
39 stars 17 forks source link

paper-icon-button is not working #9

Open hisakaz0 opened 9 years ago

hisakaz0 commented 9 years ago

Hello, @alchapone . I'm creating a rails application with this gem. I used paper-icon-button element, then, the icon(iron-icon) was not displayed.

Environments

ruby 2.2.0p0
rails 4.2.4
polymer-rails 1.1.0
polymer-elements-rails 1.0.1
sprockets 2.12.4
sprockets-rails 2.3.3

Rails error message and screenshot is below.


Started GET "/welcome/index" for 10.0.2.2 at 2015-09-08 21:00:59 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by WelcomeController#index as HTML
  Rendered welcome/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 734ms (Views: 732.7ms | ActiveRecord: 0.0ms)

Started GET "/assets/welcome-2be930bcbfd3c3e00190e2193dda5c7c.css?body=1" for 10.0.2.2 at 2015-09-08 21:01:00 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

Started GET "/assets/application-d1a275ef14480a2e8dbf7788b244d24c.css?body=1" for 10.0.2.2 at 2015-09-08 21:01:00 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

Started GET "/assets/welcome-0bc27e2168727cafa1252f703137df60.js?body=1" for 10.0.2.2 at 2015-09-08 21:01:00 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

Started GET "/assets/application-6309bddf815d3a7ea869a200dbad199c.js?body=1" for 10.0.2.2 at 2015-09-08 21:01:00 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

Started GET "/assets/%5B%5Bsrc%5D%5D" for 10.0.2.2 at 2015-09-08 21:01:00 +0000
Cannot render console from 10.0.2.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

ActionController::RoutingError (No route matches [GET] "/assets/%5B%5Bsrc%5D%5D"):
  actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  web-console (2.2.1) lib/web_console/middleware.rb:31:in `call'
  actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.4) lib/rails/engine.rb:518:in `call'
  railties (4.2.4) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

  Rendered /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.3ms)
  Rendered /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/routes/_route.html.erb (1.0ms)
  Rendered /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/routes/_table.html.erb (21.6ms)
  Rendered /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (6.0ms)
  Rendered /home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (65.7ms)

screenshot000001

glaucomunsberg commented 8 years ago

Hi @pinkienort same problem here when I update my repo

Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Installing minitest 5.8.2 (was 5.7.0)
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.1.6
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.6
Using rack 1.5.5
Using rack-test 0.6.3
Using actionpack 4.1.6
Installing mime-types 2.6.2 (was 2.6.1)
Using mail 2.6.3
Using actionmailer 4.1.6
Using activemodel 4.1.6
Using arel 5.0.1.20140414130214
Using activerecord 4.1.6
Using descendants_tracker 0.0.4
Using ice_nine 0.11.1
Using axiom-types 0.1.1
Using bcrypt 3.1.10
Using bson 3.2.6
Using bundler 1.7.6
Using carrierwave 0.10.0
Using coderay 1.1.0
Using coercible 1.0.0
Using coffee-script-source 1.9.1.1
Installing execjs 2.6.0 (was 2.5.2)
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.1.6
Using coffee-rails 4.0.1
Using orm_adapter 0.5.0
Using responders 1.1.2
Using warden 1.2.3
Installing devise 3.5.2 (was 3.5.1)
Using multi_json 1.11.2
Using elasticsearch-api 1.0.14
Using multipart-post 2.0.0
Using faraday 0.9.2
Using elasticsearch-transport 1.0.14
Using elasticsearch 1.0.14
Installing hashie 3.4.3 (was 3.4.2)
Using elasticsearch-model 0.1.8
Using equalizer 0.0.11
Using virtus 1.0.5
Using elasticsearch-persistence 0.1.8
Installing font-awesome-rails 4.4.0.0 (was 4.3.0.0)
Using tilt 1.4.1
Installing haml 4.0.7 (was 4.0.6)
Using sass 3.2.19
Using hanna-bootstrap 0.0.5
Using hike 1.2.3
Installing jbuilder 2.3.2 (was 2.3.1)
Installing jquery-rails 3.1.4 (was 3.1.3)
Installing mini_magick 4.3.6 (was 4.2.7)
Using mini_portile 0.6.2
Using mongo 2.1.2
Using origin 2.1.1
Installing mongoid 5.0.1 (was 5.0.0)
Using mysql2 0.4.1
Using nokogiri 1.6.6.2
Installing nokogumbo 1.4.5 (was 1.4.2)
Using sprockets 2.12.4
Installing sprockets-rails 2.3.3 (was 2.3.2)
Using rails 4.1.6
Installing polymer-rails 1.0.8 (was 1.0.5)
Using rdoc 4.2.0
Using sass-rails 4.0.5
Using sdoc 0.4.1
Installing spring 1.4.0 (was 1.3.6)
Installing sqlite3 1.3.11 (was 1.3.10)
Using turbolinks 2.5.3
Installing uglifier 2.7.2 (was 2.7.1)

screen shot 2015-11-05 at 8 54 41 pm

tden012 commented 8 years ago

I'm having the same issue as well. I did some digging and here's what I've found.

I am currently using paper-tabs, which has a dependency on paper-icon button. Within paper-icon-button.html is the following line:

<iron-icon id="icon" src="[[src]]" icon="[[icon]]" alt$="[[alt]]"></iron-icon>

it seems that rails is converting it from the above to this:

<iron-icon id="icon" src="%5B%5Bsrc%5D%5D" icon="[[icon]]"></iron-icon>

I'm trying to figure out how to fix it in my own project atm. But if anyone has any info on how this can be prevented, please post.

glaucomunsberg commented 8 years ago

Hi @tden012 and @pinkienort ! A poor solution until the @alchapone solve the problem is inject this code in your project for exemple. Solved, however the solution is aesthetics

paper-icon-button * img{
  display:none;
}
paper-fab * img{
  display: none;
}
tden012 commented 8 years ago

Thanks @glaucomunsberg, I'll give it a go :-)

agnewtj commented 8 years ago

Having the same problem. Is it a rails problem or a polymer problem?

glaucomunsberg commented 8 years ago

@agnewtj I believe that is a polymer-elements-rails problem 🙂

agnewtj commented 8 years ago

I think the problem is inside Sprockets. I traced Sprockets code using 'rake assets:precompile'. Nokogiri is called many times, apparently to re-code links. Nokogiri seems to recognize "src=" as a special attribute, and it appears to escape its value. Although I haven't located the spot where it happens.

As a workaround, I hacked paper-icon-button.html inside this gem, changing 'src' to 'isrc': (line 110) <iron-icon id="icon" isrc="[[src]]" icon="[[icon]]"></iron-icon>

and hacked iron-icon.html: (line 137) isrc: { (line 157) return this.icon || !this.isrc; (line 177) this._img.src = this.isrc;

Any Sprockets experts out there? I could use a pointer or a hint to track down the bug and devise a permanent fix.

glaucomunsberg commented 8 years ago

@agnewtj I suppose that it's a good way, @alchapone what you think about that?

agnewtj commented 8 years ago

I've tracked down the bug further. Here's a more sensible workaround. It's a patch to polymer-rails:

In polymer-rails/lib/polymer-rails/xml_adapters/nokogiri.rb, line 44, change:

doc.css("head,body").children.to_html(encoding: ENCODING).lstrip

to:

doc.css("head,body").children.to_html(encoding: ENCODING).lstrip.gsub(/%5B%5B/,'[[').gsub(/%5D%5D/,']]')

This seems to be the simplest patch until an upstream fix can be made to Sprockets or Nokogiri.