Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Preserve 'extends' when the ShadowDOM polyfill patches document.register - #292

Merged
arv merged 1 commit into
googlearchive:masterfrom
sigmundch:patch-1
Nov 4, 2013
Merged

Preserve 'extends' when the ShadowDOM polyfill patches document.register#292
arv merged 1 commit into
googlearchive:masterfrom
sigmundch:patch-1

Conversation

@sigmundch

Copy link
Copy Markdown
Contributor

I noticed this bug only when using the shadow-dom polyfill in combination with the native document.register. Here is a sample repro example:

<!DOCTYPE html>
<html><body>
  <script src="ShadowDOM/shadowdom.js"></script>

  <x-b></x-b> <span is="x-c"></span>

  <script>
    var bp = Object.create(HTMLElement.prototype);
    bp.createdCallback = function() { console.log("b created"); };
    var B = document.register('x-b', { prototype: bp });

    var cp = Object.create(HTMLSpanElement.prototype);
    cp.createdCallback = function() { console.log("c created"); };
    var C = document.register('x-c', { prototype: cp, extends: 'span' });
  </script>

You'd expect to see: b created and c created, but only b created is printed.

Comment thread src/wrappers/Document.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

var p = {prototype: newPrototype};
if (object.extends)
  p.extend  = object.extends;

@arv

arv commented Nov 1, 2013

Copy link
Copy Markdown
Contributor

Can you add a test too?

Before this change this worked well in combination with the custom elements polyfill, however it failed with the native document.register.
@sigmundch

Copy link
Copy Markdown
Contributor Author

good call - I had not realized that the constructor also had to be fixed (we don't hit that code path in our code). I added tests for both, passes on FF 25, Chrome 30, and Chrome 31 (where we used the polyfill + native document.register)

PTAL

@arv

arv commented Nov 4, 2013

Copy link
Copy Markdown
Contributor

LGTM

arv added a commit that referenced this pull request Nov 4, 2013
Preserve 'extends' when the ShadowDOM polyfill patches document.register
@arv
arv merged commit 67666a6 into googlearchive:master Nov 4, 2013
@martyglaubitz

Copy link
Copy Markdown

Huh ? Why am i mentioned here ? Never contributed to this repo in anyway...

@sigmundch

Copy link
Copy Markdown
Contributor Author

@martyglaubitz I think when you did a merge in your clone of here https://github.com/martyglaubitz/bleeding_edge/commit/13b7346dc9cef05c7c2cc81ad7b326eccbeb0198, you included a commit that I made which mentions this pull request.

syntheticpp pushed a commit to syntheticpp/dartruntime that referenced this pull request Nov 26, 2013
svn2github pushed a commit to svn2github/dart-lang that referenced this pull request Jul 15, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants