forked from opal/opal-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
137 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
module Browser; module DOM | ||
|
||
# TODO: DocumentFragment is not a subclass of Element, but | ||
# a subclass of Node. It implements a ParentNode. | ||
# | ||
# @see https://github.com/opal/opal-browser/pull/46 | ||
class DocumentFragment < Element | ||
def self.new(node) | ||
if self == DocumentFragment | ||
if defined? `#{node}.mode` | ||
ShadowRoot.new(node) | ||
else | ||
super | ||
end | ||
else | ||
super | ||
end | ||
end | ||
|
||
def self.create | ||
$document.create_document_fragment | ||
end | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Browser; module DOM | ||
|
||
# Document and ShadowRoot have some methods and properties in common. | ||
# This solution mimics how it's done in DOM. | ||
# | ||
# @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot | ||
module DocumentOrShadowRoot | ||
# @!attribute [r] style_sheets | ||
# @return [Array<CSS::StyleSheet>] the style sheets for the document | ||
def style_sheets | ||
Native::Array.new(`#@native.styleSheets`) {|e| | ||
CSS::StyleSheet.new(e) | ||
} | ||
end | ||
|
||
alias stylesheets style_sheets | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Browser; module DOM | ||
|
||
class ShadowRoot < DocumentFragment | ||
include DocumentOrShadowRoot | ||
|
||
# Use: Element#shadow | ||
def self.create | ||
raise ArgumentError | ||
end | ||
end | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters