New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link rel=import with package: URLs doesn't propagate correctly to relative URLs in the #11034

Closed
DartBot opened this Issue Jun 2, 2013 · 14 comments

Comments

Projects
None yet
6 participants
@DartBot

DartBot commented Jun 2, 2013

This issue was originally filed by papi...@gmail.com


To reproduce
============
Create static_test web-ui project with following 3 files:

static_test/lib/singleton.dart


class Singleton {
  static final Singleton singleton = new Singleton.();

  factory Singleton() => _singleton;

  Singleton._() {
    print('Creating singleton with hash code: $hashCode');
  }

  String toString() => hashCode.toString();
}

static_test/lib/print_singleton.html


<!DOCTYPE html>
<html>
  <body>
    <element name="print-singleton" extends="div">
      <template>Singleton in web component: {{singleton}}</template>
      <script type="application/dart">
        import 'package:web_ui/web_ui.dart';
        import 'singleton.dart';

        class PrintSingleton extends WebComponent {
          Singleton singleton = new Singleton();

          void created() {
            print("Singleton's hash code in web component: $singleton");
          }
        }
      </script>
    </element>
  </body>
</html>

static_test/web/main.html


<!DOCTYPE html>
<html>
  <head>
    <link rel="import" href="package:singleton_test/print_singleton.html">
  </head>
  <body>
    <print-singleton></print-singleton>

    <script type="application/dart">
      import 'dart:html';
      import 'package:web_ui/web_ui.dart';
      import 'package:singleton_test/singleton.dart';

      void main() {
        Singleton singleton = new Singleton();
        print("Singleton's hash code in main function: $singleton");
      }
    </script>
  </body>
</html>

Output
======
The expected output is to see same hash code 4 times.

Instead when i run the project i see following output:


Creating singleton with hash code: 866268140
Singleton's hash code in main function: 866268140
Creating singleton with hash code: 489263892
Singleton's hash code in web component: 489263892

I am using
==========
Windows 8 Pro, 64 bit
Dart Editor version 0.5.11_r23200
Dart SDK version 0.5.11.1_r23200
Web UI version 0.4.8+4

Why doesn't the static variable have a same value in same isolate?

The singleton pattern in http://stackoverflow.com/questions/12649573/how-do-you-build-a-singleton-in-dart doesn't work.

@DartBot

This comment has been minimized.

Show comment
Hide comment
@DartBot

DartBot Jun 3, 2013

This comment was originally written by papi...@gmail.com


The singleton works if i move
static_test/lib/print_singleton.html to
static_test/web/print_singleton.html.

Wierd. In my understanding they are in same package (singleton_test).

Maybe this is the Web UI issue and all components must be in under web directory.

DartBot commented Jun 3, 2013

This comment was originally written by papi...@gmail.com


The singleton works if i move
static_test/lib/print_singleton.html to
static_test/web/print_singleton.html.

Wierd. In my understanding they are in same package (singleton_test).

Maybe this is the Web UI issue and all components must be in under web directory.

@iposva-google

This comment has been minimized.

Show comment
Hide comment
@iposva-google

iposva-google Jun 5, 2013

Contributor

cc @dgrove.
Set owner to @jmesserly.
Added Area-WebUI, Triaged labels.

Contributor

iposva-google commented Jun 5, 2013

cc @dgrove.
Set owner to @jmesserly.
Added Area-WebUI, Triaged labels.

@DartBot

This comment has been minimized.

Show comment
Hide comment
@DartBot

DartBot Jul 17, 2013

This comment was originally written by integra...@gmail.com


This is similar to the issue I reported in 10696

DartBot commented Jul 17, 2013

This comment was originally written by integra...@gmail.com


This is similar to the issue I reported in 10696

@DartBot

This comment has been minimized.

Show comment
Hide comment
@DartBot

DartBot Aug 3, 2013

This comment was originally written by david.elbaze...@gmail.com


This is very problematic ! And this is not a problem in web_UI.

How could we do ? I Have no more idea... I really need static types...

DartBot commented Aug 3, 2013

This comment was originally written by david.elbaze...@gmail.com


This is very problematic ! And this is not a problem in web_UI.

How could we do ? I Have no more idea... I really need static types...

@jmesserly

This comment has been minimized.

Show comment
Hide comment
@jmesserly

jmesserly Aug 28, 2013

Member

this is caused by importing the file with what Dart sees as two distinct URLs. Dart then thinks they are two different libraries and loads it twice. I believe the problem is:

    import 'package:singleton_test/singleton.dart';

vs.

    import 'singleton.dart';

importing both with "package:" URLs, or both using file URLs should fix the problem.

However, I believe this is a flaw in how <link rel=import> and package: URLs interact. Since HTML doesn't support "package:" scheme and probably never will, I don't know what the right answer is here. I guess we could give the HTML Imports polyfill some notion of what "package:" means, but it feels hacky.

I edited the subject with more info and am assigning to Area-Polymer since I'm pretty sure it will have the same problem.


cc @sigmundch.
Removed the owner.
Removed Area-WebUI label.
Added Area-Polymer label.
Changed the title to: "link rel=import with package: URLs doesn't propagate correctly to relative URLs in the ".

Member

jmesserly commented Aug 28, 2013

this is caused by importing the file with what Dart sees as two distinct URLs. Dart then thinks they are two different libraries and loads it twice. I believe the problem is:

    import 'package:singleton_test/singleton.dart';

vs.

    import 'singleton.dart';

importing both with "package:" URLs, or both using file URLs should fix the problem.

However, I believe this is a flaw in how <link rel=import> and package: URLs interact. Since HTML doesn't support "package:" scheme and probably never will, I don't know what the right answer is here. I guess we could give the HTML Imports polyfill some notion of what "package:" means, but it feels hacky.

I edited the subject with more info and am assigning to Area-Polymer since I'm pretty sure it will have the same problem.


cc @sigmundch.
Removed the owner.
Removed Area-WebUI label.
Added Area-Polymer label.
Changed the title to: "link rel=import with package: URLs doesn't propagate correctly to relative URLs in the ".

@jmesserly

This comment has been minimized.

Show comment
Hide comment
@jmesserly
Member

jmesserly commented Aug 28, 2013

Added Library-HtmlImports label.

@jmesserly

This comment has been minimized.

Show comment
Hide comment
@jmesserly

jmesserly Aug 28, 2013

Member

Marked this as being blocked by #12867.

Member

jmesserly commented Aug 28, 2013

Marked this as being blocked by #12867.

@sigmundch

This comment has been minimized.

Show comment
Hide comment
@sigmundch

sigmundch Oct 7, 2013

Member

Added this to the M8 milestone.

Member

sigmundch commented Oct 7, 2013

Added this to the M8 milestone.

@sigmundch

This comment has been minimized.

Show comment
Hide comment
@sigmundch

sigmundch Oct 9, 2013

Member

Removed this from the M8 milestone.
Added this to the Later milestone.

Member

sigmundch commented Oct 9, 2013

Removed this from the M8 milestone.
Added this to the Later milestone.

@sigmundch

This comment has been minimized.

Show comment
Hide comment
@sigmundch

sigmundch Nov 14, 2013

Member

Removed this from the Later milestone.
Added this to the M9 milestone.

Member

sigmundch commented Nov 14, 2013

Removed this from the Later milestone.
Added this to the M9 milestone.

@clayberg

This comment has been minimized.

Show comment
Hide comment
@clayberg

clayberg Nov 15, 2013

Removed this from the M9 milestone.
Added this to the 1.1 milestone.

clayberg commented Nov 15, 2013

Removed this from the M9 milestone.
Added this to the 1.1 milestone.

@sigmundch

This comment has been minimized.

Show comment
Hide comment
@sigmundch

sigmundch Jan 28, 2014

Member

Removed this from the 1.1 milestone.
Added this to the 1.2 milestone.

Member

sigmundch commented Jan 28, 2014

Removed this from the 1.1 milestone.
Added this to the 1.2 milestone.

@anders-sandholm

This comment has been minimized.

Show comment
Hide comment
@anders-sandholm

anders-sandholm Feb 6, 2014

Contributor

Removed Library-HtmlImports label.
Added Pkg-HtmlImports label.

Contributor

anders-sandholm commented Feb 6, 2014

Removed Library-HtmlImports label.
Added Pkg-HtmlImports label.

@jmesserly

This comment has been minimized.

Show comment
Hide comment
@jmesserly

jmesserly May 13, 2014

Member

I don't think link rel=import supports package: URIs anymore


Added AssumedStale label.

Member

jmesserly commented May 13, 2014

I don't think link rel=import supports package: URIs anymore


Added AssumedStale label.

@DartBot DartBot added this to the 1.2 milestone May 13, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment